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.RSS10Generator.java

License:Open Source License

protected void populateChannel(Channel channel, Element eChannel) {
    super.populateChannel(channel, eChannel);
    if (channel.getUri() != null) {
        eChannel.setAttribute("about", channel.getUri(), getRDFNamespace());
    }//w  w  w  .  ja v a  2  s.c  om
    List items = channel.getItems();
    if (items.size() > 0) {
        Element eItems = new Element("items", getFeedNamespace());
        Element eSeq = new Element("Seq", getRDFNamespace());
        for (int i = 0; i < items.size(); i++) {
            Item item = (Item) items.get(i);
            Element eLi = new Element("li", getRDFNamespace());
            String uri = item.getUri();
            if (uri != null) {
                eLi.setAttribute("resource", uri, getRDFNamespace());
            }
            eSeq.addContent(eLi);
        }
        eItems.addContent(eSeq);
        eChannel.addContent(eItems);
    }
}

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

License:Open Source License

protected void populateItem(Item item, Element eItem, int index) {
    super.populateItem(item, eItem, index);
    String link = item.getLink();
    String uri = item.getUri();//from  w  w w .j av  a  2 s  .  c  o  m

    if (uri != null) {
        eItem.setAttribute("about", uri, getRDFNamespace());
    } else if (link != null) {
        eItem.setAttribute("about", link, getRDFNamespace());
    }

    Description description = item.getDescription();
    if (description != null) {
        eItem.addContent(generateSimpleElement("description", description.getValue()));
    }
    if (item.getModule(getContentNamespace().getURI()) == null && item.getContent() != null) {
        Element elem = new Element("encoded", getContentNamespace());
        elem.addContent(item.getContent().getValue());
        eItem.addContent(elem);
    }
}

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

License:Open Source License

public void generate(Module module, Element element) {

    SyModule syModule = (SyModule) module;

    if (syModule.getUpdatePeriod() != null) {
        Element updatePeriodElement = new Element("updatePeriod", SY_NS);
        updatePeriodElement.addContent(syModule.getUpdatePeriod());
        element.addContent(updatePeriodElement);
    }/*from   w  w  w .  j av a  2  s. co m*/

    Element updateFrequencyElement = new Element("updateFrequency", SY_NS);
    updateFrequencyElement.addContent(String.valueOf(syModule.getUpdateFrequency()));
    element.addContent(updateFrequencyElement);

    if (syModule.getUpdateBase() != null) {
        Element updateBaseElement = new Element("updateBase", SY_NS);
        updateBaseElement.addContent(DateParser.formatW3CDateTime(syModule.getUpdateBase()));
        element.addContent(updateBaseElement);
    }
}

From source file:com.thoughtworks.go.config.MagicalGoConfigXmlWriter.java

License:Apache License

private static Element elementFor(Class<?> aClass, ConfigCache configCache) {
    final AttributeAwareConfigTag attributeAwareConfigTag = annotationFor(aClass,
            AttributeAwareConfigTag.class);

    if (attributeAwareConfigTag != null) {
        final Element element = new Element(attributeAwareConfigTag.value(),
                namespaceFor(attributeAwareConfigTag));
        element.setAttribute(attributeAwareConfigTag.attribute(), attributeAwareConfigTag.attributeValue());
        return element;
    }//from   w  ww.j a v a 2  s .c  om

    ConfigTag configTag = annotationFor(aClass, ConfigTag.class);
    if (configTag == null)
        throw bomb(format("Cannot get config tag for {0}", aClass));
    return new Element(configTag.value(), namespaceFor(configTag));
}