List of usage examples for org.jdom2 Element Element
public Element(final String name, final String uri)
From source file:com.rometools.rome.io.impl.RSS091UserlandGenerator.java
License:Open Source License
@Override protected Element createRootElement(final Channel channel) { final Element root = new Element("rss", getFeedNamespace()); final Attribute version = new Attribute("version", getVersion()); root.setAttribute(version);/*from ww w. j a v a2s. c o m*/ root.addNamespaceDeclaration(getContentNamespace()); generateModuleNamespaceDefs(root); return root; }
From source file:com.rometools.rome.io.impl.RSS091UserlandGenerator.java
License:Open Source License
protected Element generateSkipHoursElement(final List<Integer> hours) { final Element skipHoursElement = new Element("skipHours", getFeedNamespace()); for (final Integer hour : hours) { skipHoursElement.addContent(generateSimpleElement("hour", hour.toString())); }//from ww w . j a v a 2 s. c o m return skipHoursElement; }
From source file:com.rometools.rome.io.impl.RSS091UserlandGenerator.java
License:Open Source License
@Override protected void populateItem(final Item item, final Element eItem, final int index) { super.populateItem(item, eItem, index); final Description description = item.getDescription(); if (description != null) { eItem.addContent(generateSimpleElement("description", description.getValue())); }//from w ww . j a va 2 s . co m final Namespace contentNamespace = getContentNamespace(); final Content content = item.getContent(); if (item.getModule(contentNamespace.getURI()) == null && content != null) { final Element elem = new Element("encoded", contentNamespace); elem.addContent(content.getValue()); eItem.addContent(elem); } }
From source file:com.rometools.rome.io.impl.RSS092Generator.java
License:Open Source License
protected Element generateCloud(final Cloud cloud) { final Element eCloud = new Element("cloud", getFeedNamespace()); final String domain = cloud.getDomain(); if (domain != null) { eCloud.setAttribute(new Attribute("domain", domain)); }/*from www .j av a 2 s . c o m*/ final int port = cloud.getPort(); if (port != 0) { eCloud.setAttribute(new Attribute("port", String.valueOf(port))); } final String path = cloud.getPath(); if (path != null) { eCloud.setAttribute(new Attribute("path", path)); } final String registerProcedure = cloud.getRegisterProcedure(); if (registerProcedure != null) { eCloud.setAttribute(new Attribute("registerProcedure", registerProcedure)); } final String protocol = cloud.getProtocol(); if (protocol != null) { eCloud.setAttribute(new Attribute("protocol", protocol)); } return eCloud; }
From source file:com.rometools.rome.io.impl.RSS092Generator.java
License:Open Source License
protected Element generateSourceElement(final Source source) { final Element sourceElement = new Element("source", getFeedNamespace()); final String url = source.getUrl(); if (url != null) { sourceElement.setAttribute(new Attribute("url", url)); }/* w ww . j a v a 2 s .c o m*/ sourceElement.addContent(source.getValue()); return sourceElement; }
From source file:com.rometools.rome.io.impl.RSS092Generator.java
License:Open Source License
protected Element generateEnclosure(final Enclosure enclosure) { final Element enclosureElement = new Element("enclosure", getFeedNamespace()); final String url = enclosure.getUrl(); if (url != null) { enclosureElement.setAttribute("url", url); }/*from w ww . ja v a2 s . c o m*/ final long length = enclosure.getLength(); if (length != 0) { enclosureElement.setAttribute("length", String.valueOf(length)); } final String type = enclosure.getType(); if (type != null) { enclosureElement.setAttribute("type", type); } return enclosureElement; }
From source file:com.rometools.rome.io.impl.RSS092Generator.java
License:Open Source License
protected Element generateCategoryElement(final Category category) { final Element categoryElement = new Element("category", getFeedNamespace()); final String domain = category.getDomain(); if (domain != null) { categoryElement.setAttribute("domain", domain); }/*from www. j a v a 2 s . co m*/ categoryElement.addContent(category.getValue()); return categoryElement; }
From source file:com.rometools.rome.io.impl.RSS10Generator.java
License:Open Source License
@Override protected void populateChannel(final Channel channel, final Element eChannel) { super.populateChannel(channel, eChannel); final String channelUri = channel.getUri(); if (channelUri != null) { eChannel.setAttribute("about", channelUri, getRDFNamespace()); }//w w w .j a va 2 s .c o m final List<Item> items = channel.getItems(); if (!items.isEmpty()) { final Element eItems = new Element("items", getFeedNamespace()); final Element eSeq = new Element("Seq", getRDFNamespace()); for (final Item item : items) { final Element lis = new Element("li", getRDFNamespace()); final String uri = item.getUri(); if (uri != null) { lis.setAttribute("resource", uri, getRDFNamespace()); } eSeq.addContent(lis); } eItems.addContent(eSeq); eChannel.addContent(eItems); } }
From source file:com.rometools.rome.io.impl.RSS10Generator.java
License:Open Source License
@Override protected void populateItem(final Item item, final Element eItem, final int index) { super.populateItem(item, eItem, index); final String link = item.getLink(); final String uri = item.getUri(); if (uri != null) { eItem.setAttribute("about", uri, getRDFNamespace()); } else if (link != null) { eItem.setAttribute("about", link, getRDFNamespace()); }/*from ww w .j a va2 s. c om*/ final Description description = item.getDescription(); if (description != null) { eItem.addContent(generateSimpleElement("description", description.getValue())); } if (item.getModule(getContentNamespace().getURI()) == null && item.getContent() != null) { final Element elem = new Element("encoded", getContentNamespace()); elem.addContent(item.getContent().getValue()); eItem.addContent(elem); } }
From source file:com.rometools.rome.io.impl.SyModuleGenerator.java
License:Open Source License
@Override public void generate(final Module module, final Element element) { final SyModule syModule = (SyModule) module; final String updatePeriod = syModule.getUpdatePeriod(); if (updatePeriod != null) { final Element updatePeriodElement = new Element("updatePeriod", SY_NS); updatePeriodElement.addContent(updatePeriod); element.addContent(updatePeriodElement); }//www .j a va 2 s. c om final Element updateFrequencyElement = new Element("updateFrequency", SY_NS); updateFrequencyElement.addContent(String.valueOf(syModule.getUpdateFrequency())); element.addContent(updateFrequencyElement); final Date updateBase = syModule.getUpdateBase(); if (updateBase != null) { final Element updateBaseElement = new Element("updateBase", SY_NS); updateBaseElement.addContent(DateParser.formatW3CDateTime(updateBase, Locale.US)); element.addContent(updateBaseElement); } }