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.Atom03Generator.java
License:Open Source License
protected Element generateTagLineElement(final Content tagline) { final Element taglineElement = new Element("tagline", getFeedNamespace()); final String type = tagline.getType(); if (type != null) { final Attribute typeAttribute = new Attribute("type", type); taglineElement.setAttribute(typeAttribute); }//from w w w .j av a2s . c om final String value = tagline.getValue(); if (value != null) { taglineElement.addContent(value); } return taglineElement; }
From source file:com.rometools.rome.io.impl.Atom03Generator.java
License:Open Source License
protected Element generateGeneratorElement(final Generator generator) { final Element generatorElement = new Element("generator", getFeedNamespace()); final String url = generator.getUrl(); if (url != null) { final Attribute urlAttribute = new Attribute("url", url); generatorElement.setAttribute(urlAttribute); }//from w ww . ja va 2 s . c o m final String version = generator.getVersion(); if (version != null) { final Attribute versionAttribute = new Attribute("version", version); generatorElement.setAttribute(versionAttribute); } final String value = generator.getValue(); if (value != null) { generatorElement.addContent(value); } return generatorElement; }
From source file:com.rometools.rome.io.impl.Atom03Generator.java
License:Open Source License
protected Element generateSimpleElement(final String name, final String value) { final Element element = new Element(name, getFeedNamespace()); element.addContent(value);/*from ww w .j a va 2s . c o m*/ return element; }
From source file:com.rometools.rome.io.impl.Atom10Generator.java
License:Open Source License
protected Element createRootElement(final Feed feed) { final Element root = new Element("feed", getFeedNamespace()); root.addNamespaceDeclaration(getFeedNamespace()); // Attribute version = new Attribute("version", getVersion()); // root.setAttribute(version); final String xmlBase = feed.getXmlBase(); if (xmlBase != null) { root.setAttribute("base", xmlBase, Namespace.XML_NAMESPACE); }//www. j ava2 s. c om generateModuleNamespaceDefs(root); return root; }
From source file:com.rometools.rome.io.impl.Atom10Generator.java
License:Open Source License
protected void addEntry(final Entry entry, final Element parent) throws FeedException { final Element eEntry = new Element("entry", getFeedNamespace()); final String xmlBase = entry.getXmlBase(); if (xmlBase != null) { eEntry.setAttribute("base", xmlBase, Namespace.XML_NAMESPACE); }/*from ww w. j ava2 s. c om*/ populateEntry(entry, eEntry); generateForeignMarkup(eEntry, entry.getForeignMarkup()); checkEntryConstraints(eEntry); generateItemModules(entry.getModules(), eEntry); parent.addContent(eEntry); }
From source file:com.rometools.rome.io.impl.Atom10Generator.java
License:Open Source License
protected void populateFeedHeader(final Feed feed, final Element eFeed) throws FeedException { final Content titleEx = feed.getTitleEx(); if (titleEx != null) { final Element titleElement = new Element("title", getFeedNamespace()); fillContentElement(titleElement, titleEx); eFeed.addContent(titleElement);/*from w w w . j a v a 2s . c o m*/ } final List<Link> alternateLinks = feed.getAlternateLinks(); if (alternateLinks != null) { for (final Link link : alternateLinks) { eFeed.addContent(generateLinkElement(link)); } } final List<Link> otherLinks = feed.getOtherLinks(); if (otherLinks != null) { for (final Link link : otherLinks) { eFeed.addContent(generateLinkElement(link)); } } final List<Category> cats = feed.getCategories(); if (cats != null) { for (final Category category : cats) { eFeed.addContent(generateCategoryElement(category)); } } final List<SyndPerson> authors = feed.getAuthors(); if (Lists.isNotEmpty(authors)) { for (final SyndPerson author : authors) { final Element authorElement = new Element("author", getFeedNamespace()); fillPersonElement(authorElement, author); eFeed.addContent(authorElement); } } final List<SyndPerson> contributors = feed.getContributors(); if (Lists.isNotEmpty(contributors)) { for (final SyndPerson contributor : contributors) { final Element contributorElement = new Element("contributor", getFeedNamespace()); fillPersonElement(contributorElement, contributor); eFeed.addContent(contributorElement); } } final Content subtitle = feed.getSubtitle(); if (subtitle != null) { final Element subtitleElement = new Element("subtitle", getFeedNamespace()); fillContentElement(subtitleElement, subtitle); eFeed.addContent(subtitleElement); } final String id = feed.getId(); if (id != null) { eFeed.addContent(generateSimpleElement("id", id)); } final Generator generator = feed.getGenerator(); if (generator != null) { eFeed.addContent(generateGeneratorElement(generator)); } final String rights = feed.getRights(); if (rights != null) { eFeed.addContent(generateSimpleElement("rights", rights)); } final String icon = feed.getIcon(); if (icon != null) { eFeed.addContent(generateSimpleElement("icon", icon)); } final String logo = feed.getLogo(); if (logo != null) { eFeed.addContent(generateSimpleElement("logo", logo)); } final Date updated = feed.getUpdated(); if (updated != null) { final Element updatedElement = new Element("updated", getFeedNamespace()); updatedElement.addContent(DateParser.formatW3CDateTime(updated, Locale.US)); eFeed.addContent(updatedElement); } }
From source file:com.rometools.rome.io.impl.Atom10Generator.java
License:Open Source License
protected void populateEntry(final Entry entry, final Element eEntry) throws FeedException { final Content titleEx = entry.getTitleEx(); if (titleEx != null) { final Element titleElement = new Element("title", getFeedNamespace()); fillContentElement(titleElement, titleEx); eEntry.addContent(titleElement); }//from w ww .j a va 2 s .co m final List<Link> alternateLinks = entry.getAlternateLinks(); if (alternateLinks != null) { for (final Link link : alternateLinks) { eEntry.addContent(generateLinkElement(link)); } } final List<Link> otherLinks = entry.getOtherLinks(); if (otherLinks != null) { for (final Link link : otherLinks) { eEntry.addContent(generateLinkElement(link)); } } final List<Category> cats = entry.getCategories(); if (cats != null) { for (final Category category : cats) { eEntry.addContent(generateCategoryElement(category)); } } final List<SyndPerson> authors = entry.getAuthors(); if (Lists.isNotEmpty(authors)) { for (final SyndPerson author : authors) { final Element authorElement = new Element("author", getFeedNamespace()); fillPersonElement(authorElement, author); eEntry.addContent(authorElement); } } final List<SyndPerson> contributors = entry.getContributors(); if (Lists.isNotEmpty(contributors)) { for (final SyndPerson contributor : contributors) { final Element contributorElement = new Element("contributor", getFeedNamespace()); fillPersonElement(contributorElement, contributor); eEntry.addContent(contributorElement); } } final String id = entry.getId(); if (id != null) { eEntry.addContent(generateSimpleElement("id", id)); } final Date updated = entry.getUpdated(); if (updated != null) { final Element updatedElement = new Element("updated", getFeedNamespace()); updatedElement.addContent(DateParser.formatW3CDateTime(updated, Locale.US)); eEntry.addContent(updatedElement); } final Date published = entry.getPublished(); if (published != null) { final Element publishedElement = new Element("published", getFeedNamespace()); publishedElement.addContent(DateParser.formatW3CDateTime(published, Locale.US)); eEntry.addContent(publishedElement); } final List<Content> contents = entry.getContents(); if (Lists.isNotEmpty(contents)) { final Element contentElement = new Element("content", getFeedNamespace()); final Content content = contents.get(0); fillContentElement(contentElement, content); eEntry.addContent(contentElement); } final Content summary = entry.getSummary(); if (summary != null) { final Element summaryElement = new Element("summary", getFeedNamespace()); fillContentElement(summaryElement, summary); eEntry.addContent(summaryElement); } final Feed source = entry.getSource(); if (source != null) { final Element sourceElement = new Element("source", getFeedNamespace()); populateFeedHeader(source, sourceElement); eEntry.addContent(sourceElement); } }
From source file:com.rometools.rome.io.impl.Atom10Generator.java
License:Open Source License
protected Element generateCategoryElement(final Category cat) { final Namespace namespace = getFeedNamespace(); final Element catElement = new Element("category", namespace); final String term = cat.getTerm(); if (term != null) { final Attribute termAttribute = new Attribute("term", term); catElement.setAttribute(termAttribute); }/*w w w. j av a 2s . c o m*/ final String label = cat.getLabel(); if (label != null) { final Attribute labelAttribute = new Attribute("label", label); catElement.setAttribute(labelAttribute); } final String scheme = cat.getScheme(); if (scheme != null) { final Attribute schemeAttribute = new Attribute("scheme", scheme); catElement.setAttribute(schemeAttribute); } return catElement; }
From source file:com.rometools.rome.io.impl.Atom10Generator.java
License:Open Source License
protected Element generateLinkElement(final Link link) { final Namespace namespace = getFeedNamespace(); final Element linkElement = new Element("link", namespace); final String rel = link.getRel(); if (rel != null) { final Attribute relAttribute = new Attribute("rel", rel); linkElement.setAttribute(relAttribute); }//from w w w .j a v a 2 s. co m final String type = link.getType(); if (type != null) { final Attribute typeAttribute = new Attribute("type", type); linkElement.setAttribute(typeAttribute); } final String href = link.getHref(); if (href != null) { final Attribute hrefAttribute = new Attribute("href", href); linkElement.setAttribute(hrefAttribute); } final String hreflang = link.getHreflang(); if (hreflang != null) { final Attribute hreflangAttribute = new Attribute("hreflang", hreflang); linkElement.setAttribute(hreflangAttribute); } final String linkTitle = link.getTitle(); if (linkTitle != null) { final Attribute title = new Attribute("title", linkTitle); linkElement.setAttribute(title); } if (link.getLength() != 0) { final Attribute lenght = new Attribute("length", Long.toString(link.getLength())); linkElement.setAttribute(lenght); } return linkElement; }
From source file:com.rometools.rome.io.impl.Atom10Generator.java
License:Open Source License
protected Element generateTagLineElement(final Content tagline) { final Element taglineElement = new Element("subtitle", getFeedNamespace()); final String type = tagline.getType(); if (type != null) { final Attribute typeAttribute = new Attribute("type", type); taglineElement.setAttribute(typeAttribute); }//from w ww. j ava2 s.com final String value = tagline.getValue(); if (value != null) { taglineElement.addContent(value); } return taglineElement; }