Example usage for org.jdom2 Element Element

List of usage examples for org.jdom2 Element Element

Introduction

In this page you can find the example usage for org.jdom2 Element Element.

Prototype

public Element(final String name, final String uri) 

Source Link

Document

Creates a new element with the supplied (local) name and a namespace given by a URI.

Usage

From source file:com.sun.syndication.io.impl.Atom03Generator.java

License:Open Source License

protected Element createRootElement(Feed feed) {
    Element root = new Element("feed", getFeedNamespace());
    root.addNamespaceDeclaration(getFeedNamespace());
    Attribute version = new Attribute("version", getVersion());
    root.setAttribute(version);/*w  ww.j  a  v a 2  s.c o m*/
    generateModuleNamespaceDefs(root);
    return root;
}

From source file:com.sun.syndication.io.impl.Atom03Generator.java

License:Open Source License

protected void addEntry(Entry entry, Element parent) throws FeedException {
    Element eEntry = new Element("entry", getFeedNamespace());
    populateEntry(entry, eEntry);//  w  w w . ja v  a  2s . com
    checkEntryConstraints(eEntry);
    generateItemModules(entry.getModules(), eEntry);
    parent.addContent(eEntry);
}

From source file:com.sun.syndication.io.impl.Atom03Generator.java

License:Open Source License

protected void populateFeedHeader(Feed feed, Element eFeed) throws FeedException {
    if (feed.getTitleEx() != null) {
        Element titleElement = new Element("title", getFeedNamespace());
        fillContentElement(titleElement, feed.getTitleEx());
        eFeed.addContent(titleElement);//w  w  w  .  j  a  v  a2 s .c  om
    }

    List links = feed.getAlternateLinks();
    for (int i = 0; i < links.size(); i++) {
        eFeed.addContent(generateLinkElement((Link) links.get(i)));
    }

    links = feed.getOtherLinks();
    for (int i = 0; i < links.size(); i++) {
        eFeed.addContent(generateLinkElement((Link) links.get(i)));
    }
    if (feed.getAuthors() != null && feed.getAuthors().size() > 0) {
        Element authorElement = new Element("author", getFeedNamespace());
        fillPersonElement(authorElement, (Person) feed.getAuthors().get(0));
        eFeed.addContent(authorElement);
    }

    List contributors = feed.getContributors();
    for (int i = 0; i < contributors.size(); i++) {
        Element contributorElement = new Element("contributor", getFeedNamespace());
        fillPersonElement(contributorElement, (Person) contributors.get(i));
        eFeed.addContent(contributorElement);
    }

    if (feed.getTagline() != null) {
        Element taglineElement = new Element("tagline", getFeedNamespace());
        fillContentElement(taglineElement, feed.getTagline());
        eFeed.addContent(taglineElement);
    }

    if (feed.getId() != null) {
        eFeed.addContent(generateSimpleElement("id", feed.getId()));
    }

    if (feed.getGenerator() != null) {
        eFeed.addContent(generateGeneratorElement(feed.getGenerator()));
    }

    if (feed.getCopyright() != null) {
        eFeed.addContent(generateSimpleElement("copyright", feed.getCopyright()));
    }

    if (feed.getInfo() != null) {
        Element infoElement = new Element("info", getFeedNamespace());
        fillContentElement(infoElement, feed.getInfo());
        eFeed.addContent(infoElement);
    }

    if (feed.getModified() != null) {
        Element modifiedElement = new Element("modified", getFeedNamespace());
        modifiedElement.addContent(DateParser.formatW3CDateTime(feed.getModified()));
        eFeed.addContent(modifiedElement);
    }
}

From source file:com.sun.syndication.io.impl.Atom03Generator.java

License:Open Source License

protected void populateEntry(Entry entry, Element eEntry) throws FeedException {
    if (entry.getTitleEx() != null) {
        Element titleElement = new Element("title", getFeedNamespace());
        fillContentElement(titleElement, entry.getTitleEx());
        eEntry.addContent(titleElement);
    }//w ww .j  a  va  2  s . com
    List links = entry.getAlternateLinks();
    for (int i = 0; i < links.size(); i++) {
        eEntry.addContent(generateLinkElement((Link) links.get(i)));
    }

    links = entry.getOtherLinks();
    for (int i = 0; i < links.size(); i++) {
        eEntry.addContent(generateLinkElement((Link) links.get(i)));
    }

    if (entry.getAuthors() != null && entry.getAuthors().size() > 0) {
        Element authorElement = new Element("author", getFeedNamespace());
        fillPersonElement(authorElement, (Person) entry.getAuthors().get(0));
        eEntry.addContent(authorElement);
    }

    List contributors = entry.getContributors();
    for (int i = 0; i < contributors.size(); i++) {
        Element contributorElement = new Element("contributor", getFeedNamespace());
        fillPersonElement(contributorElement, (Person) contributors.get(i));
        eEntry.addContent(contributorElement);
    }
    if (entry.getId() != null) {
        eEntry.addContent(generateSimpleElement("id", entry.getId()));
    }

    if (entry.getModified() != null) {
        Element modifiedElement = new Element("modified", getFeedNamespace());
        modifiedElement.addContent(DateParser.formatW3CDateTime(entry.getModified()));
        eEntry.addContent(modifiedElement);
    }

    if (entry.getIssued() != null) {
        Element issuedElement = new Element("issued", getFeedNamespace());
        issuedElement.addContent(DateParser.formatW3CDateTime(entry.getIssued()));
        eEntry.addContent(issuedElement);
    }

    if (entry.getCreated() != null) {
        Element createdElement = new Element("created", getFeedNamespace());
        createdElement.addContent(DateParser.formatW3CDateTime(entry.getCreated()));
        eEntry.addContent(createdElement);
    }

    if (entry.getSummary() != null) {
        Element summaryElement = new Element("summary", getFeedNamespace());
        fillContentElement(summaryElement, entry.getSummary());
        eEntry.addContent(summaryElement);
    }

    List contents = entry.getContents();
    for (int i = 0; i < contents.size(); i++) {
        Element contentElement = new Element("content", getFeedNamespace());
        fillContentElement(contentElement, (Content) contents.get(i));
        eEntry.addContent(contentElement);
    }

    generateForeignMarkup(eEntry, (List) entry.getForeignMarkup());
}

From source file:com.sun.syndication.io.impl.Atom03Generator.java

License:Open Source License

protected Element generateLinkElement(Link link) {
    Element linkElement = new Element("link", getFeedNamespace());

    if (link.getRel() != null) {
        Attribute relAttribute = new Attribute("rel", link.getRel().toString());
        linkElement.setAttribute(relAttribute);
    }//from  w  ww .  j av a 2 s.  c o m

    if (link.getType() != null) {
        Attribute typeAttribute = new Attribute("type", link.getType());
        linkElement.setAttribute(typeAttribute);
    }

    if (link.getHref() != null) {
        Attribute hrefAttribute = new Attribute("href", link.getHref());
        linkElement.setAttribute(hrefAttribute);
    }
    return linkElement;
}

From source file:com.sun.syndication.io.impl.Atom03Generator.java

License:Open Source License

protected Element generateTagLineElement(Content tagline) {
    Element taglineElement = new Element("tagline", getFeedNamespace());

    if (tagline.getType() != null) {
        Attribute typeAttribute = new Attribute("type", tagline.getType());
        taglineElement.setAttribute(typeAttribute);
    }//from   w  w w .j av a 2 s . c om

    if (tagline.getValue() != null) {
        taglineElement.addContent(tagline.getValue());
    }
    return taglineElement;
}

From source file:com.sun.syndication.io.impl.Atom03Generator.java

License:Open Source License

protected Element generateGeneratorElement(Generator generator) {
    Element generatorElement = new Element("generator", getFeedNamespace());

    if (generator.getUrl() != null) {
        Attribute urlAttribute = new Attribute("url", generator.getUrl());
        generatorElement.setAttribute(urlAttribute);
    }/*from  w w  w. j  a  v a  2  s . c  o m*/

    if (generator.getVersion() != null) {
        Attribute versionAttribute = new Attribute("version", generator.getVersion());
        generatorElement.setAttribute(versionAttribute);
    }

    if (generator.getValue() != null) {
        generatorElement.addContent(generator.getValue());
    }

    return generatorElement;

}

From source file:com.sun.syndication.io.impl.Atom03Generator.java

License:Open Source License

protected Element generateSimpleElement(String name, String value) {
    Element element = new Element(name, getFeedNamespace());
    element.addContent(value);//from  www  . j av a 2  s .  co m
    return element;
}

From source file:com.sun.syndication.io.impl.Atom10Generator.java

License:Open Source License

protected Element createRootElement(Feed feed) {
    Element root = new Element("feed", getFeedNamespace());
    root.addNamespaceDeclaration(getFeedNamespace());
    //Attribute version = new Attribute("version", getVersion());
    //root.setAttribute(version);
    if (feed.getXmlBase() != null) {
        root.setAttribute("base", feed.getXmlBase(), Namespace.XML_NAMESPACE);
    }//from   w  w w  .java 2  s .  c o  m
    generateModuleNamespaceDefs(root);
    return root;
}

From source file:com.sun.syndication.io.impl.Atom10Generator.java

License:Open Source License

protected void addEntry(Entry entry, Element parent) throws FeedException {
    Element eEntry = new Element("entry", getFeedNamespace());
    if (entry.getXmlBase() != null) {
        eEntry.setAttribute("base", entry.getXmlBase(), Namespace.XML_NAMESPACE);
    }//from  w ww .j  a  va2s  .  c o  m
    populateEntry(entry, eEntry);
    generateForeignMarkup(eEntry, (List) entry.getForeignMarkup());
    checkEntryConstraints(eEntry);
    generateItemModules(entry.getModules(), eEntry);
    parent.addContent(eEntry);
}