List of usage examples for org.jdom2 Element getChildren
public List<Element> getChildren(final String cname)
List
of all the child elements nested directly (one level deep) within this element with the given local name and belonging to no namespace, returned as Element
objects. From source file:com.ohnosequences.xml.model.mg7.ReadResultXML.java
License:Open Source License
public List<Hit> getHits() throws XMLElementException { Element elem = initHitsTag(); List<Hit> resultList = new LinkedList<Hit>(); List<Element> tempList = elem.getChildren(Hit.TAG_NAME); for (Element element : tempList) { resultList.add(new Hit(element)); }/*w ww .ja v a2 s .c o m*/ return resultList; }
From source file:com.ohnosequences.xml.model.PredictedGene.java
License:Open Source License
public ArrayList<Frameshift> getFrameshifts() throws XMLElementException { ArrayList<Frameshift> array = null; Element temp = root.getChild(FRAME_SHIFTS_TAG_NAME); if (temp != null) { array = new ArrayList<Frameshift>(); List<Element> list = temp.getChildren(Frameshift.TAG_NAME); for (Element elem : list) { Frameshift frameshift = new Frameshift(elem); array.add(frameshift);/*from w w w. j a v a2 s. c om*/ } } return array; }
From source file:com.ohnosequences.xml.model.PredictedRna.java
License:Open Source License
public ArrayList<Frameshift> getFrameshifts() throws XMLElementException { ArrayList<Frameshift> array = new ArrayList<>(); Element temp = root.getChild(FRAME_SHIFTS_TAG_NAME); if (temp != null) { List<Element> list = temp.getChildren(Frameshift.TAG_NAME); for (Element elem : list) { Frameshift frameshift = new Frameshift(elem); array.add(frameshift);/*from ww w .j ava 2 s . c o m*/ } } return array; }
From source file:com.ohnosequences.xml.model.uniprot.ProteinXML.java
License:Open Source License
public List<KeywordXML> getKeywords() throws XMLElementException { List<KeywordXML> list = new ArrayList<KeywordXML>(); Element keywords = root.getChild(KEYWORDS_TAG_NAME); List<Element> elemList = keywords.getChildren(KeywordXML.TAG_NAME); for (Element elem : elemList) { list.add(new KeywordXML(elem)); }/*from www. j a v a 2s.c o m*/ return list; }
From source file:com.ohnosequences.xml.model.uniprot.ProteinXML.java
License:Open Source License
public List<GoTermXML> getMolecularFunctionGoTerms() { Element goTerms = root.getChild(GO_TERMS_TAG_NAME); if (goTerms != null) { Element molFunc = goTerms.getChild(FUNCTION_GO_TERMS_TAG_NAME); if (molFunc != null) { List<Element> gos = molFunc.getChildren(GoTermXML.TAG_NAME); ArrayList<GoTermXML> result = new ArrayList<GoTermXML>(); for (Element elem : gos) { result.add(new GoTermXML(elem)); }//from w ww . j a v a 2 s. c o m return result; } else { return null; } } else { return null; } }
From source file:com.ohnosequences.xml.model.uniprot.ProteinXML.java
License:Open Source License
public List<GoTermXML> getBiologicalProcessGoTerms() { Element goTerms = root.getChild(GO_TERMS_TAG_NAME); if (goTerms != null) { Element bioProc = goTerms.getChild(PROCESS_GO_TERMS_TAG_NAME); if (bioProc != null) { List<Element> gos = bioProc.getChildren(GoTermXML.TAG_NAME); ArrayList<GoTermXML> result = new ArrayList<GoTermXML>(); for (Element elem : gos) { result.add(new GoTermXML(elem)); }//from w w w. j a v a 2 s . co m return result; } else { return null; } } else { return null; } }
From source file:com.ohnosequences.xml.model.uniprot.ProteinXML.java
License:Open Source License
public List<GoTermXML> getCellularComponentGoTerms() { Element goTerms = root.getChild(GO_TERMS_TAG_NAME); if (goTerms != null) { Element cellComp = goTerms.getChild(COMPONENT_GO_TERMS_TAG_NAME); if (cellComp != null) { List<Element> gos = cellComp.getChildren(GoTermXML.TAG_NAME); ArrayList<GoTermXML> result = new ArrayList<GoTermXML>(); for (Element elem : gos) { result.add(new GoTermXML(elem)); }/*ww w . ja v a2s . co m*/ return result; } else { return null; } } else { return null; } }
From source file:com.rometools.modules.cc.io.ModuleParserRSS2.java
License:Open Source License
@Override public Module parse(final Element element, final Locale locale) { final CreativeCommonsImpl module = new CreativeCommonsImpl(); // Do channel global {/*ww w . j ava 2 s.c om*/ Element root = element; while (!root.getName().equals("channel") && !root.getName().equals("feed")) { root = root.getParentElement(); } final ArrayList<License> licenses = new ArrayList<License>(); List<Element> items = null; if (root.getName().equals("channel")) { items = root.getChildren("item"); } else { items = root.getChildren("entry"); } final Iterator<Element> iit = items.iterator(); while (iit.hasNext()) { final Element item = iit.next(); final List<Element> licenseTags = item.getChildren("license", NS); final Iterator<Element> lit = licenseTags.iterator(); while (lit.hasNext()) { final Element licenseTag = lit.next(); final License license = License.findByValue(licenseTag.getTextTrim()); if (!licenses.contains(license)) { ; } licenses.add(license); } } if (!licenses.isEmpty()) { module.setAllLicenses(licenses.toArray(new License[0])); } } // do element local final ArrayList<License> licenses = new ArrayList<License>(); final List<Element> licenseTags = element.getChildren("license", NS); final Iterator<Element> it = licenseTags.iterator(); while (it.hasNext()) { final Element licenseTag = it.next(); licenses.add(License.findByValue(licenseTag.getTextTrim())); } if (!licenses.isEmpty()) { module.setLicenses(licenses.toArray(new License[0])); } if (module.getLicenses() != null && module.getAllLicenses() != null) { return module; } else { return null; } }
From source file:com.rometools.opml.io.impl.OPML10Parser.java
License:Apache License
protected Outline parseOutline(final Element e, final boolean validate, final Locale locale) throws FeedException { if (!e.getName().equals("outline")) { throw new RuntimeException("Not an outline element."); }/*from w w w . j a v a2 s . c om*/ final Outline outline = new Outline(); outline.setText(e.getAttributeValue("text")); outline.setType(e.getAttributeValue("type")); outline.setTitle(e.getAttributeValue("title")); final List<org.jdom2.Attribute> jAttributes = e.getAttributes(); final ArrayList<Attribute> attributes = new ArrayList<Attribute>(); for (int i = 0; i < jAttributes.size(); i++) { final org.jdom2.Attribute a = jAttributes.get(i); if (!a.getName().equals("isBreakpoint") && !a.getName().equals("isComment") && !a.getName().equals("title") && !a.getName().equals("text") && !a.getName().equals("type")) { attributes.add(new Attribute(a.getName(), a.getValue())); } } outline.setAttributes(attributes); try { outline.setBreakpoint(readBoolean(e.getAttributeValue("isBreakpoint"))); } catch (final Exception ex) { LOG.warn("Unable to parse isBreakpoint value", ex); if (validate) { throw new FeedException("Unable to parse isBreakpoint value", ex); } } try { outline.setComment(readBoolean(e.getAttributeValue("isComment"))); } catch (final Exception ex) { LOG.warn("Unable to parse isComment value", ex); if (validate) { throw new FeedException("Unable to parse isComment value", ex); } } final List<Element> children = e.getChildren("outline"); outline.setModules(parseItemModules(e, locale)); outline.setChildren(parseOutlines(children, validate, locale)); return outline; }
From source file:com.rometools.rome.io.impl.OPML10Parser.java
License:Apache License
protected Outline parseOutline(final Element e, final boolean validate, final Locale locale) throws FeedException { if (!e.getName().equals("outline")) { throw new RuntimeException("Not an outline element."); }//from w ww.j ava2s .com final Outline outline = new Outline(); outline.setText(e.getAttributeValue("text")); outline.setType(e.getAttributeValue("type")); outline.setTitle(e.getAttributeValue("title")); final List<org.jdom2.Attribute> jAttributes = e.getAttributes(); final ArrayList<Attribute> attributes = new ArrayList<Attribute>(); for (int i = 0; i < jAttributes.size(); i++) { final org.jdom2.Attribute a = jAttributes.get(i); if (!a.getName().equals("isBreakpoint") && !a.getName().equals("isComment") && !a.getName().equals("title") && !a.getName().equals("text") && !a.getName().equals("type")) { attributes.add(new Attribute(a.getName(), a.getValue())); } } outline.setAttributes(attributes); try { outline.setBreakpoint(readBoolean(e.getAttributeValue("isBreakpoint"))); } catch (final Exception ex) { if (validate) { throw new FeedException("Unable to parse isBreakpoint value", ex); } } try { outline.setComment(readBoolean(e.getAttributeValue("isComment"))); } catch (final Exception ex) { if (validate) { throw new FeedException("Unable to parse isComment value", ex); } } final List<Element> children = e.getChildren("outline"); outline.setModules(parseItemModules(e, locale)); outline.setChildren(parseOutlines(children, validate, locale)); return outline; }