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.rometools.rome.io.impl.Atom10Generator.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("uri", url);
        generatorElement.setAttribute(urlAttribute);
    }//from  w w w . java 2 s.  co m

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

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

    return generatorElement;

}

From source file:com.rometools.rome.io.impl.CBModuleGenerator.java

License:Apache License

/**
 * Utility method to generate an element for a speech.
 * <p>/*from  ww w  .  j  a  v  a  2  s .  c  o m*/
 *
 * @param speech the speech to generate an element for.
 * @return the element for the speech.
 */
protected final Element generateSpeechElement(final CBSpeech speech) {

    final Element speechElement = new Element("speech", getCBNamespace());
    final String simpleTitle = speech.getSimpleTitle();

    if (simpleTitle != null) {
        final Element simpleTitleElement = new Element("simpleTitle", getCBNamespace());
        simpleTitleElement.addContent(simpleTitle);
        speechElement.addContent(simpleTitleElement);
    }
    return speechElement;
}

From source file:com.rometools.rome.io.impl.CBModuleGenerator.java

License:Apache License

/**
 * Utility method to generate a single element containing a string.
 * <p>//from  w  w w. ja  va2 s . c  o m
 *
 * @param name the name of the elment to generate.
 * @param value the value of the text in the element.
 * @return the element generated.
 */
protected final Element generateSimpleElement(final String name, final String value) {
    final Element element = new Element(name, getCBNamespace());
    element.addContent(value);
    return element;
}

From source file:com.rometools.rome.io.impl.DCModuleGenerator.java

License:Open Source License

/**
 * Utility method to generate an element for a subject.
 * <p>/*from w  w w  . j av  a 2 s . co m*/
 *
 * @param subject the subject to generate an element for.
 * @return the element for the subject.
 */
protected final Element generateSubjectElement(final DCSubject subject) {

    final Element subjectElement = new Element("subject", getDCNamespace());

    final String taxonomyUri = subject.getTaxonomyUri();
    final String value = subject.getValue();

    if (taxonomyUri != null) {

        final Attribute resourceAttribute = new Attribute("resource", taxonomyUri, getRDFNamespace());

        final Element topicElement = new Element("topic", getTaxonomyNamespace());
        topicElement.setAttribute(resourceAttribute);

        final Element descriptionElement = new Element("Description", getRDFNamespace());
        descriptionElement.addContent(topicElement);

        if (value != null) {
            final Element valueElement = new Element("value", getRDFNamespace());
            valueElement.addContent(value);
            descriptionElement.addContent(valueElement);
        }

        subjectElement.addContent(descriptionElement);

    } else {
        subjectElement.addContent(value);
    }

    return subjectElement;
}

From source file:com.rometools.rome.io.impl.DCModuleGenerator.java

License:Open Source License

/**
 * Utility method to generate a single element containing a string.
 * <p>//ww  w  .  j  a  v  a  2 s. co  m
 *
 * @param name the name of the elment to generate.
 * @param value the value of the text in the element.
 * @return the element generated.
 */
protected final Element generateSimpleElement(final String name, final String value) {
    final Element element = new Element(name, getDCNamespace());
    element.addContent(value);
    return element;
}

From source file:com.rometools.rome.io.impl.RSS090Generator.java

License:Open Source License

protected Element createRootElement(final Channel channel) {
    final Element root = new Element("RDF", getRDFNamespace());
    root.addNamespaceDeclaration(getFeedNamespace());
    root.addNamespaceDeclaration(getRDFNamespace());
    root.addNamespaceDeclaration(getContentNamespace());
    generateModuleNamespaceDefs(root);//from  ww  w.  ja  v a  2s  .c  om
    return root;
}

From source file:com.rometools.rome.io.impl.RSS090Generator.java

License:Open Source License

protected void addChannel(final Channel channel, final Element parent) throws FeedException {
    final Element eChannel = new Element("channel", getFeedNamespace());
    populateChannel(channel, eChannel);/*from  ww  w.ja va 2  s. c  o m*/
    checkChannelConstraints(eChannel);
    parent.addContent(eChannel);
    generateFeedModules(channel.getModules(), eChannel);
}

From source file:com.rometools.rome.io.impl.RSS090Generator.java

License:Open Source License

protected void addImage(final Channel channel, final Element parent) throws FeedException {
    final Image image = channel.getImage();
    if (image != null) {
        final Element eImage = new Element("image", getFeedNamespace());
        populateImage(image, eImage);/*from  w w w  .j  a v  a  2s  .  c  o  m*/
        checkImageConstraints(eImage);
        parent.addContent(eImage);
    }
}

From source file:com.rometools.rome.io.impl.RSS090Generator.java

License:Open Source License

protected void addTextInput(final Channel channel, final Element parent) throws FeedException {
    final TextInput textInput = channel.getTextInput();
    if (textInput != null) {
        final Element eTextInput = new Element(getTextInputLabel(), getFeedNamespace());
        populateTextInput(textInput, eTextInput);
        checkTextInputConstraints(eTextInput);
        parent.addContent(eTextInput);/* w w w  . j  a va2 s  . com*/
    }
}

From source file:com.rometools.rome.io.impl.RSS090Generator.java

License:Open Source License

protected void addItem(final Item item, final Element parent, final int index) throws FeedException {
    final Element eItem = new Element("item", getFeedNamespace());
    populateItem(item, eItem, index);//from   ww w . ja  va2s . c  o m
    checkItemConstraints(eItem);
    generateItemModules(item.getModules(), eItem);
    parent.addContent(eItem);
}