List of usage examples for org.jdom2 Element addContent
@Override public Element addContent(final Collection<? extends Content> newContent)
From source file:com.rometools.rome.io.impl.RSS091UserlandGenerator.java
License:Open Source License
@Override protected void populateImage(final Image image, final Element eImage) { super.populateImage(image, eImage); final Integer width = image.getWidth(); if (width != null) { eImage.addContent(generateSimpleElement("width", String.valueOf(width))); }// w w w . j a va 2s . c o m final Integer height = image.getHeight(); if (height != null) { eImage.addContent(generateSimpleElement("height", String.valueOf(height))); } final String description = image.getDescription(); if (description != null) { eImage.addContent(generateSimpleElement("description", description)); } }
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 v a2 s . c o 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
@Override protected void populateChannel(final Channel channel, final Element eChannel) { super.populateChannel(channel, eChannel); final Cloud cloud = channel.getCloud(); if (cloud != null) { eChannel.addContent(generateCloud(cloud)); }//from w ww. jav a2 s.c om }
From source file:com.rometools.rome.io.impl.RSS092Generator.java
License:Open Source License
@Override protected void populateItem(final Item item, final Element eItem, final int index) { super.populateItem(item, eItem, index); final Source source = item.getSource(); if (source != null) { eItem.addContent(generateSourceElement(source)); }/*from w ww .j av a 2 s . com*/ final List<Enclosure> enclosures = item.getEnclosures(); for (int i = 0; i < getNumberOfEnclosures(enclosures); i++) { eItem.addContent(generateEnclosure(enclosures.get(i))); } final List<Category> categories = item.getCategories(); for (final Category category : categories) { eItem.addContent(generateCategoryElement(category)); } }
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)); }/* www . j av 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 generateCategoryElement(final Category category) { final Element categoryElement = new Element("category", getFeedNamespace()); final String domain = category.getDomain(); if (domain != null) { categoryElement.setAttribute("domain", domain); }//w ww . jav a 2s . c o m categoryElement.addContent(category.getValue()); return categoryElement; }
From source file:com.rometools.rome.io.impl.RSS093Generator.java
License:Open Source License
@Override protected void populateItem(final Item item, final Element eItem, final int index) { super.populateItem(item, eItem, index); final Date pubDate = item.getPubDate(); if (pubDate != null) { eItem.addContent(generateSimpleElement("pubDate", DateParser.formatRFC822(pubDate, Locale.US))); }/* www . ja v a 2s . com*/ final Date expirationDate = item.getExpirationDate(); if (expirationDate != null) { eItem.addContent( generateSimpleElement("expirationDate", DateParser.formatRFC822(expirationDate, Locale.US))); } }
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()); }//from ww w. j a v a 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()); }/*ww w .j a va 2s.co m*/ 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.RSS20Generator.java
License:Open Source License
@Override protected void populateChannel(final Channel channel, final Element eChannel) { super.populateChannel(channel, eChannel); final String generator = channel.getGenerator(); if (generator != null) { eChannel.addContent(generateSimpleElement("generator", generator)); }//from ww w . j a va2 s . co m final int ttl = channel.getTtl(); if (ttl > -1) { eChannel.addContent(generateSimpleElement("ttl", String.valueOf(ttl))); } final List<Category> categories = channel.getCategories(); for (final Category category : categories) { eChannel.addContent(generateCategoryElement(category)); } generateForeignMarkup(eChannel, channel.getForeignMarkup()); }