List of usage examples for org.jdom2 Document getRootElement
public Element getRootElement()
Element
for this Document
From source file:com.thoughtworks.go.util.SvnLogXmlParser.java
License:Apache License
public HashMap<String, String> parseInfoToGetUUID(String output, String queryURL, SAXBuilder builder) { HashMap<String, String> uidToUrlMap = new HashMap<>(); try {/* w w w . ja v a 2 s . c o m*/ Document document = builder.build(new StringReader(output)); Element root = document.getRootElement(); List<Element> entries = root.getChildren("entry"); for (Element entry : entries) { uidToUrlMap.put(queryURL, entry.getChild("repository").getChild("uuid").getValue()); } } catch (Exception e) { throw new RuntimeException(e); } return uidToUrlMap; }
From source file:com.thoughtworks.xstream.io.xml.JDom2Reader.java
License:Open Source License
/** * @since 1.4.5 */ public JDom2Reader(Document document) { super(document.getRootElement()); }
From source file:com.thoughtworks.xstream.io.xml.JDom2Reader.java
License:Open Source License
/** * @since 1.4.5 */ public JDom2Reader(Document document, NameCoder nameCoder) { super(document.getRootElement(), nameCoder); }
From source file:com.ucuenca.dao.BaseXMLDao.java
public Table getTable() throws MalformedURLException, JDOMException, IOException { SAXBuilder builder = new SAXBuilder(); URL url = new URL(path); InputStream stream = url.openStream(); Document document = null; try {/*ww w . j a v a2s . c o m*/ document = builder.build(stream); } catch (JDOMException e) { } Table table = new Table_Excel(); // Get Root Element and name Element root = document.getRootElement(); String rootName = root.getName(); // Get Second Level Elements, the rows of the data table List<Element> items = root.getChildren(); // Get column names, using the first element List<Element> firstItem = items.get(0).getChildren(); List<Column> columns = new ArrayList<Column>(); for (Element col : firstItem) { Column column = new Column(); column.setTitle(col.getName()); column.setStorageFormat(formatColumn(""));//pendiente columns.add(column); } // Get data and identify type data // for (Element item : items) { // ArrayList<String> row = new ArrayList<String>(); // for (Element col : item.getChildren()) { // row.add(col.getText()); // } // // } return table; }
From source file:com.versionmaintain.files.LastVersionInfosParser.java
License:Apache License
public List<VersionInfo> getVersionInfo() { SAXBuilder builder = new SAXBuilder(); List<VersionInfo> infos = new ArrayList<VersionInfo>(); try {// ww w . java 2 s . com Document doc = builder.build(new File(System.getProperty("user.dir") + File.separator + FILE_NAME)); Element root = doc.getRootElement(); List<Element> softEles = root.getChildren("software"); for (Element softEle : softEles) { String appName = softEle.getAttribute("name").getValue(); String versionCode = softEle.getChildText("latest-version-code"); String versionName = softEle.getChildText("latest-version"); Element detailEles = softEle.getChild("latest-version-detail"); List<Element> detailItemEles = detailEles.getChildren("item"); List<VersionInfoDetail> details = new ArrayList<VersionInfoDetail>(); for (Element detailItem : detailItemEles) { String title = detailItem.getAttributeValue("name"); List<Element> detailEleList = detailItem.getChildren("detail"); List<String> detailList = new ArrayList<String>(); for (Element detailEle : detailEleList) { String strDetail = detailEle.getText(); detailList.add(strDetail); } details.add(new VersionInfoDetail(title, detailList)); } VersionInfo versionInfo = new VersionInfo(); versionInfo.setAppName(appName); versionInfo.setVersion(versionName); versionInfo.setVersionCode(Integer.parseInt(versionCode)); versionInfo.setDetails(details); infos.add(versionInfo); } } catch (Exception e) { e.printStackTrace(); } return infos; }
From source file:com.xebialabs.overcast.support.libvirt.DomainWrapper.java
License:Apache License
private void updateFilesystemMappings(Document cloneXmlDocument, List<Filesystem> mappings) { Element devices = cloneXmlDocument.getRootElement().getChild("devices"); Map<String, Filesystem> currentFilesystems = getFilesystems(domainXml); for (Filesystem fs : mappings) { if (currentFilesystems.containsKey(fs.target)) { removeFilesystemsWithTarget(cloneXmlDocument, fs.target); }// w w w . ja va 2s. c om devices.addContent(toFileSystemXml(fs)); } }
From source file:com.xebialabs.overcast.support.libvirt.jdom.DomainXml.java
License:Apache License
/** remove elements that need to be unique per clone. */ public static Document prepareForCloning(Document domainXml) { XPathFactory xpf = XPathFactory.instance(); // remove uuid so it will be generated domainXml.getRootElement().removeChild("uuid"); // remove mac address, so it will be generated XPathExpression<Element> macExpr = xpf.compile("/domain/devices/interface/mac", Filters.element()); for (Element mac : macExpr.evaluate(domainXml)) { mac.getParentElement().removeChild("mac"); }/*from w ww .j ava 2 s .c om*/ return domainXml; }
From source file:com.xebialabs.overcast.support.libvirt.Metadata.java
License:Apache License
private static Element getMetadataElement(Document domainXml) { Element metadata = domainXml.getRootElement().getChild(METADATA); if (metadata == null) { return null; }/*from www .ja v a 2 s .c o m*/ return metadata; }
From source file:com.xebialabs.overcast.support.libvirt.Metadata.java
License:Apache License
public static void updateProvisioningMetadata(Document domainXml, String baseDomainName, String provisionCmd, String expirationTag, Date creationTime) { checkArgument(baseDomainName, "baseDomainName"); checkArgument(provisionCmd, "provisionCmd"); checkArgument(expirationTag, "expirationTag"); Preconditions.checkNotNull(creationTime, "creationTime must not be null"); Element element = getMetadataElement(domainXml); if (element != null) { domainXml.getRootElement().removeContent(element); }/*w w w . jav a 2 s. c o m*/ Element metadata = createProvisioningMetadata(baseDomainName, provisionCmd, expirationTag, creationTime); domainXml.getRootElement().addContent(metadata); }
From source file:com.xebialabs.overcast.support.libvirt.Metadata.java
License:Apache License
public static void updateCloneMetadata(Document domainXml, String baseDomainName, Date creationTime) { checkArgument(baseDomainName, "baseDomainName"); Preconditions.checkNotNull(creationTime, "creationTime must not be null"); Element element = getMetadataElement(domainXml); if (element != null) { domainXml.getRootElement().removeContent(element); }/*from w w w . j a va2 s .co m*/ Element metadata = createCloningMetadata(baseDomainName, creationTime); domainXml.getRootElement().addContent(metadata); }