List of usage examples for org.jdom2 Element getName
public String getName()
From source file:it.intecs.pisa.openCatalogue.solr.ingester.Ingester.java
protected static void generateDefaultMap(Element el, Map map) { String key = ""; List<Element> listEmpElement = el.getChildren(); if (el.getName().equals("indexFieldName")) { key = el.getTextTrim();/*from w w w . j ava 2 s . c o m*/ // System.out.println("key:" + key); map.put(key, ""); } else { for (Element empElement : listEmpElement) { generateDefaultMap(empElement, map); } } }
From source file:it.isislab.floasys.core.security.users.UserAccountXMLParser.java
License:Open Source License
public List<UserAccount> parse(InputStream is) throws CannotParseException { try {//from ww w . j a va2 s . c om Document doc = new SAXBuilder().build(is); Element rootNode = doc.getRootElement(); List<Element> elUsers = rootNode.getChildren(EL_USERACCOUNT); for (Element elUser : elUsers) { UserAccount userAccount = new UserAccount(); List<Element> children = elUser.getChildren(); for (Element child : children) { String childName = child.getName(); if (childName.equals(EL_USERNAME)) { } else if (childName.equals(EL_PASSWORD)) { } else if (childName.equals(EL_ACTIVATIONCODE)) { } else if (childName.equals(EL_ACTIVATED)) { } } //EndFor. } } catch (Exception e) { throw new CannotParseException(e); } return null; }
From source file:jdomexercises.LeerHijos.java
public static void main(String args[]) { try {//from ww w . j a v a2 s . c om SAXBuilder builder = new SAXBuilder(); Document doc = builder.build(new FileInputStream("C:\\Users\\Alumnot\\Documents\\ej1.xml")); // Leer la raiz Element root = doc.getRootElement(); // Devuelve la raz System.out.println(root.getName() + ", Nombre: " + root.getAttributeValue("Nombre") + ", Ubicacion: " + root.getAttributeValue("Ubicacion")); // Creamos una lista que contendra los hijos de root List<Element> t = root.getChildren("Tipo"); // Si hubiera otro hijo habra que ahcer otro getChildren() Iterator it = t.iterator(); while (it.hasNext()) { Element e = (Element) it.next(); Element c = e.getChild("Computadora"); System.out.println(c.getName() + ", Nombre: " + c.getAttributeValue("Nombre") + ", Precio: " + c.getAttributeValue("Precio")); c = e.getChild("Historieta"); System.out.println(c.getName() + ", Nombre: " + c.getAttributeValue("Nombre") + ", Precio: " + c.getAttributeValue("Precio")); c = e.getChild("Nivel"); System.out.println(c.getName() + ", Nombre: " + c.getAttributeValue("Nombre")); } } catch (JDOMException ex) { ex.printStackTrace(); } catch (IOException ex) { ex.printStackTrace(); } }
From source file:jmri.implementation.configurexml.MergSD2SignalHeadXml.java
License:Open Source License
NamedBeanHandle<Turnout> loadTurnout(Object o) { Element e = (Element) o; if (e.getName().equals("turnout")) { String name = e.getAttribute("systemName").getValue(); Turnout t;/*from w w w.j av a 2 s . c o m*/ if (e.getAttribute("userName") != null && !e.getAttribute("userName").getValue().equals("")) { name = e.getAttribute("userName").getValue(); t = InstanceManager.turnoutManagerInstance().getTurnout(name); } else { t = InstanceManager.turnoutManagerInstance().getBySystemName(name); } return jmri.InstanceManager.getDefault(jmri.NamedBeanHandleManager.class).getNamedBeanHandle(name, t); } else { String name = e.getText(); Turnout t = InstanceManager.turnoutManagerInstance().provideTurnout(name); return jmri.InstanceManager.getDefault(jmri.NamedBeanHandleManager.class).getNamedBeanHandle(name, t); } }
From source file:jmri.implementation.DefaultIdTag.java
License:Open Source License
@Override public void load(Element e) { if (e.getName().equals("idtag")) { //NOI18N if (log.isDebugEnabled()) { log.debug("Load IdTag element for " + this.getSystemName()); }/* ww w. j av a 2 s. c o m*/ if (e.getChild("userName") != null) //NOI18N { this.setUserName(e.getChild("userName").getText()); //NOI18N } if (e.getChild("comment") != null) //NOI18N { this.setComment(e.getChild("comment").getText()); //NOI18N } if (e.getChild("whereLastSeen") != null) { //NOI18N this.setWhereLastSeen(InstanceManager.reporterManagerInstance() .provideReporter(e.getChild("whereLastSeen").getText())); //NOI18N this._whenLastSeen = null; } if (e.getChild("whenLastSeen") != null) { //NOI18N log.debug("When Last Seen: " + e.getChild("whenLastSeen").getText()); try { this._whenLastSeen = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM) .parse(e.getChild("whenLastSeen").getText()); //NOI18N } catch (ParseException ex) { log.warn("Error parsing when last seen: " + ex); } } } else { log.error("Not an IdTag element: " + e.getName()); } }
From source file:jmri.jmrix.loconet.cmdstnconfig.XmlConfig.java
License:Open Source License
@SuppressWarnings("unchecked") static void dumpNode(Element node, int depth) { int leader;/* w w w.j ava 2 s . com*/ for (leader = 0; leader < depth; leader++) { System.out.print('\t'); } System.out.print(node.getName()); Iterator<Attribute> attributes = node.getAttributes().iterator(); Attribute attribute; while (attributes.hasNext()) { attribute = attributes.next(); System.out.print(" " + attribute.getName() + " = " + attribute.getValue()); } System.out.println(); Iterator<Element> children = node.getChildren().iterator(); depth++; while (children.hasNext()) { dumpNode(children.next(), depth); } }
From source file:jodtemplate.pptx.postprocessor.StylePostprocessor.java
License:Apache License
private int injectElementsInDocument(final List<Element> stylizedElements, final Element ap, final Element apPr, final int arIndex) { int index = arIndex; final Element txBody = ap.getParentElement(); int apIndex = txBody.indexOf(ap) + 1; boolean createNewAp = false; Element currentAp = ap;//from w w w .ja v a 2 s .c o m for (Element element : stylizedElements) { if (element.getName().equals(PPTXDocument.P_ELEMENT)) { currentAp = element; txBody.addContent(apIndex, currentAp); apIndex++; createNewAp = true; } else { if (createNewAp) { currentAp = new Element(PPTXDocument.P_ELEMENT, getNamespace()); Element apPrToAdd = ObjectUtils.clone(apPr); if (apPrToAdd == null) { apPrToAdd = new Element(PPTXDocument.PPR_ELEMENT, getNamespace()); } final Element abuNone = new Element(PPTXDocument.BUNONE_ELEMENT, getNamespace()); apPrToAdd.addContent(abuNone); currentAp.addContent(apPrToAdd); txBody.addContent(apIndex, currentAp); apIndex++; createNewAp = false; } if (currentAp == ap) { currentAp.addContent(index, element); index++; } else { currentAp.addContent(element); } } } return apIndex; }
From source file:jodtemplate.pptx.postprocessor.StylePostprocessor.java
License:Apache License
private List<Element> getRemainingElements(final int fromIndex, final Element ap) { final List<Element> remains = new ArrayList<>(); for (int i = fromIndex; i < ap.getContentSize(); ++i) { final Content apChild = ap.getContent(i); if (apChild instanceof Element) { final Element apChildElement = (Element) apChild; if (PPTXDocument.R_ELEMENT.equals(apChildElement.getName()) || PPTXDocument.BR_ELEMENT.equals(apChildElement.getName())) { remains.add(apChildElement); }//from w w w . jav a 2 s . c o m } } return remains; }
From source file:jodtemplate.pptx.preprocessor.FormatTagsPreprocessor.java
License:Apache License
private List<Element> processArAndABrElements(final List<Element> apChildrenList, final Parser parser) { final List<Element> arabrElementsListResult = new ArrayList<>(apChildrenList.size()); for (Element child : apChildrenList) { if (PPTXDocument.R_ELEMENT.equals(child.getName())) { final String text = child.getChild(PPTXDocument.T_ELEMENT, getNamespace()).getText(); final List<String> parsed = parser.parse(text); for (String part : parsed) { if (StringUtils.isNotEmpty(part)) { final Element arOut = child.clone(); arOut.getChild(PPTXDocument.T_ELEMENT, getNamespace()).setText(part); arabrElementsListResult.add(arOut); }//from w ww. j av a 2 s.c o m } } else if (PPTXDocument.BR_ELEMENT.equals(child.getName())) { final Element abrOut = child.clone(); arabrElementsListResult.add(abrOut); } } return arabrElementsListResult; }
From source file:jodtemplate.pptx.style.HtmlStylizer.java
License:Apache License
private List<Element> createListElements(final List<org.jsoup.nodes.Element> tags, final List<Element> elements, final Element apPr, final org.jsoup.nodes.Element element) { final Element ap = new Element(PPTXDocument.P_ELEMENT, getDrawingmlNamespace()); final Element apPrToAdd = applyListFormatting(tags, element, apPr); ap.addContent(apPrToAdd);/*w w w . ja va 2 s .c om*/ final List<Element> listResult = new ArrayList<>(); listResult.add(ap); for (Element el : elements) { if (PPTXDocument.P_ELEMENT.equals(el.getName())) { listResult.add(el); } else { ap.addContent(el); } } return listResult; }