List of usage examples for org.jdom2 Element addContent
@Override public Element addContent(final Collection<? extends Content> newContent)
From source file:com.ohnosequences.xml.model.PredictedGene.java
License:Open Source License
public void setStartCodon(Codon codon) { initStartCodonTag();// w w w. j av a 2 s .c om Element temp = root.getChild(START_CODON_TAG_NAME); temp.removeChildren(Codon.TAG_NAME); temp.addContent(codon.getRoot()); }
From source file:com.ohnosequences.xml.model.PredictedGene.java
License:Open Source License
public void setStopCodon(Codon codon) { initStopCodonTag();//from w w w .j ava 2 s . c o m Element temp = root.getChild(STOP_CODON_TAG_NAME); temp.removeChildren(Codon.TAG_NAME); temp.addContent(codon.getRoot()); }
From source file:com.ohnosequences.xml.model.wip.WipResult.java
License:Open Source License
public void addPosition(WipPosition p) { Element elem = initPositionsTag(); elem.addContent(p.getRoot()); }
From source file:com.rometools.modules.atom.io.AtomModuleGenerator.java
License:Apache License
private void generateLinks(List<Link> links, Element element) { for (Link link : links) { element.addContent(generateLink(link)); }/* w ww . j a va2s. co m*/ }
From source file:com.rometools.modules.base.io.CustomTagGenerator.java
License:Open Source License
@Override public void generate(final Module module, final Element element) { if (!(module instanceof CustomTags)) { return;//from www .java 2 s . com } final List<CustomTag> tags = ((CustomTags) module).getValues(); final Iterator<CustomTag> it = tags.iterator(); while (it.hasNext()) { final CustomTag tag = it.next(); if (tag.getValue() instanceof DateTimeRange) { final DateTimeRange dtr = (DateTimeRange) tag.getValue(); final Element newTag = new Element(tag.getName(), CustomTagParser.NS); newTag.setAttribute("type", "dateTimeRange"); newTag.addContent( generateSimpleElement("start", GoogleBaseParser.LONG_DT_FMT.format(dtr.getStart()))); newTag.addContent(generateSimpleElement("end", GoogleBaseParser.LONG_DT_FMT.format(dtr.getEnd()))); element.addContent(newTag); } else if (tag.getValue() instanceof ShortDate) { final ShortDate sd = (ShortDate) tag.getValue(); final Element newTag = generateSimpleElement(tag.getName(), GoogleBaseParser.SHORT_DT_FMT.format(sd)); newTag.setAttribute("type", "date"); element.addContent(newTag); } else if (tag.getValue() instanceof Date) { final Date d = (Date) tag.getValue(); final Element newTag = generateSimpleElement(tag.getName(), GoogleBaseParser.SHORT_DT_FMT.format(d)); newTag.setAttribute("type", "dateTime"); element.addContent(newTag); } else if (tag.getValue() instanceof Integer) { final Element newTag = generateSimpleElement(tag.getName(), tag.getValue().toString()); newTag.setAttribute("type", "int"); element.addContent(newTag); } else if (tag.getValue() instanceof IntUnit) { final Element newTag = generateSimpleElement(tag.getName(), tag.getValue().toString()); newTag.setAttribute("type", "intUnit"); element.addContent(newTag); } else if (tag.getValue() instanceof Float) { final Element newTag = generateSimpleElement(tag.getName(), tag.getValue().toString()); newTag.setAttribute("type", "float"); element.addContent(newTag); } else if (tag.getValue() instanceof FloatUnit) { final Element newTag = generateSimpleElement(tag.getName(), tag.getValue().toString()); newTag.setAttribute("type", "floatUnit"); element.addContent(newTag); } else if (tag.getValue() instanceof String) { final Element newTag = generateSimpleElement(tag.getName(), tag.getValue().toString()); newTag.setAttribute("type", "string"); element.addContent(newTag); } else if (tag.getValue() instanceof URL) { final Element newTag = generateSimpleElement(tag.getName(), tag.getValue().toString()); newTag.setAttribute("type", "url"); element.addContent(newTag); } else if (tag.getValue() instanceof Boolean) { final Element newTag = generateSimpleElement(tag.getName(), tag.getValue().toString()); newTag.setAttribute("type", "boolean"); element.addContent(newTag); } else if (tag.getValue() instanceof CustomTagImpl.Location) { final Element newTag = generateSimpleElement(tag.getName(), tag.getValue().toString()); newTag.setAttribute("type", "location"); element.addContent(newTag); } } }
From source file:com.rometools.modules.base.io.CustomTagGenerator.java
License:Open Source License
protected Element generateSimpleElement(final String name, final String value) { final Element element = new Element(name, CustomTagParser.NS); element.addContent(value); return element; }
From source file:com.rometools.modules.base.io.GoogleBaseGenerator.java
License:Open Source License
@Override public void generate(final Module module, final Element element) { final GoogleBaseImpl mod = (GoogleBaseImpl) module; final HashMap<Object, Object> props2tags = new HashMap<Object, Object>(GoogleBaseParser.PROPS2TAGS); final PropertyDescriptor[] pds = GoogleBaseParser.pds; for (final PropertyDescriptor pd : pds) { final String tagName = (String) props2tags.get(pd.getName()); if (tagName == null) { continue; }/*from w w w.j a v a 2s. com*/ Object[] values = null; try { if (pd.getPropertyType().isArray()) { values = (Object[]) pd.getReadMethod().invoke(mod, (Object[]) null); } else { values = new Object[] { pd.getReadMethod().invoke(mod, (Object[]) null) }; } for (int j = 0; values != null && j < values.length; j++) { if (values[j] != null) { element.addContent(generateTag(values[j], tagName)); } } } catch (final Exception e) { e.printStackTrace(); } } }
From source file:com.rometools.modules.base.io.GoogleBaseGenerator.java
License:Open Source License
public Element generateTag(final Object o, final String tagName) { if (o instanceof URL || o instanceof Float || o instanceof Boolean || o instanceof Integer || o instanceof String || o instanceof FloatUnit || o instanceof IntUnit || o instanceof GenderEnumeration || o instanceof PaymentTypeEnumeration || o instanceof PriceTypeEnumeration || o instanceof CurrencyEnumeration || o instanceof Size || o instanceof YearType) { return generateSimpleElement(tagName, o.toString()); } else if (o instanceof ShortDate) { return generateSimpleElement(tagName, GoogleBaseParser.SHORT_DT_FMT.format(o)); } else if (o instanceof Date) { return generateSimpleElement(tagName, GoogleBaseParser.LONG_DT_FMT.format(o)); } else if (o instanceof ShippingType) { final ShippingType st = (ShippingType) o; final Element element = new Element(tagName, GoogleBaseGenerator.NS); element.addContent(generateSimpleElement("country", st.getCountry())); element.addContent(generateSimpleElement("service", st.getService().toString())); element.addContent(generateSimpleElement("price", st.getPrice().toString())); return element; } else if (o instanceof DateTimeRange) { final DateTimeRange dtr = (DateTimeRange) o; final Element element = new Element(tagName, GoogleBaseGenerator.NS); element.addContent(generateSimpleElement("start", GoogleBaseParser.LONG_DT_FMT.format(dtr.getStart()))); element.addContent(generateSimpleElement("end", GoogleBaseParser.LONG_DT_FMT.format(dtr.getEnd()))); return element; }/*from w ww . j av a 2s . com*/ throw new RuntimeException("Unknown class type to handle: " + o.getClass().getName()); }
From source file:com.rometools.modules.base.io.GoogleBaseGenerator.java
License:Open Source License
protected Element generateSimpleElement(final String name, final String value) { final Element element = new Element(name, GoogleBaseGenerator.NS); element.addContent(value); return element; }
From source file:com.rometools.modules.cc.io.CCModuleGenerator.java
License:Open Source License
private void generateRSS1(final CreativeCommons module, final Element element) { // throw new RuntimeException( "Generating RSS1 Feeds not currently Supported."); LOG.debug(element.getName());/*from w w w .j av a 2 s. c o m*/ if (element.getName().equals("channel")) { // Do all licenses list. final License[] all = module.getAllLicenses(); for (final License element2 : all) { final Element license = new Element("License", RSS1); license.setAttribute("about", element2.getValue(), RDF); final License.Behaviour[] permits = element2.getPermits(); for (int j = 0; permits != null && j < permits.length; j++) { final Element permit = new Element("permits", RSS1); permit.setAttribute("resource", permits[j].toString(), RDF); license.addContent(permit); } final License.Behaviour[] requires = element2.getPermits(); for (int j = 0; requires != null && j < requires.length; j++) { final Element permit = new Element("requires", RSS1); permit.setAttribute("resource", permits[j].toString(), RDF); license.addContent(permit); } LOG.debug("Is Root? {}", element.getParentElement()); element.getParentElement().addContent(license); } } // Do local licenses final License[] licenses = module.getLicenses(); for (final License license2 : licenses) { final Element license = new Element("license", RSS1); license.setAttribute("resource", license2.getValue(), RDF); element.addContent(license); } }