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) 

Source Link

Document

Create a new element with the supplied (local) name and no namespace.

Usage

From source file:com.ohnosequences.xml.model.util.XMLWrapperClass.java

License:Open Source License

public XMLWrapperClass() {
    super(new Element(TAG_NAME));
}

From source file:com.ohnosequences.xml.model.wip.Region.java

License:Open Source License

public Region() {
    super(new Element(TAG_NAME));
}

From source file:com.ohnosequences.xml.model.wip.WipPosition.java

License:Open Source License

public WipPosition() {
    super(new Element(TAG_NAME));
}

From source file:com.ohnosequences.xml.model.wip.WipResult.java

License:Open Source License

public WipResult() {
    super(new Element(TAG_NAME));
}

From source file:com.ohnosequences.xml.model.wip.WipResult.java

License:Open Source License

private Element initPositionsTag() {
    Element elem = root.getChild(POSITIONS_TAG_NAME);
    if (elem == null) {
        elem = new Element(POSITIONS_TAG_NAME);
        root.addContent(elem);/*from  w  w w  .  j av a2 s. co  m*/
    }
    return elem;
}

From source file:com.ohnosequences.xml.model.wip.WipResult.java

License:Open Source License

private Element initRegionATag() {
    Element elem = root.getChild(REGION_A_TAG_NAME);
    if (elem == null) {
        elem = new Element(REGION_A_TAG_NAME);
        root.addContent(elem);/*from   ww  w  .j  av  a2s .  c o  m*/
    }
    return elem;
}

From source file:com.ohnosequences.xml.model.wip.WipResult.java

License:Open Source License

private Element initRegionBTag() {
    Element elem = root.getChild(REGION_B_TAG_NAME);
    if (elem == null) {
        elem = new Element(REGION_B_TAG_NAME);
        root.addContent(elem);/*from  ww  w.jav a2s.  co  m*/
    }
    return elem;
}

From source file:com.rometools.opml.io.impl.OPML10Generator.java

License:Apache License

/**
 * Creates an XML document (JDOM) for the given feed bean.
 *
 * @param feed the feed bean to generate the XML document from.
 * @return the generated XML document (JDOM).
 * @throws IllegalArgumentException thrown if the type of the given feed bean does not match with the type of the
 *             WireFeedGenerator.//from  w w w.  j a v  a  2  s  .c om
 * @throws FeedException thrown if the XML Document could not be created.
 */
@Override
public Document generate(final WireFeed feed) throws IllegalArgumentException, FeedException {

    if (!(feed instanceof Opml)) {
        throw new IllegalArgumentException("Not an OPML file");
    }

    final Opml opml = (Opml) feed;
    final Document doc = new Document();
    final Element root = new Element("opml");
    root.setAttribute("version", "1.0");
    doc.addContent(root);

    final Element head = generateHead(opml);

    if (head != null) {
        root.addContent(head);
    }

    final Element body = new Element("body");
    root.addContent(body);
    super.generateFeedModules(opml.getModules(), root);
    body.addContent(generateOutlines(opml.getOutlines()));

    return doc;
}

From source file:com.rometools.opml.io.impl.OPML10Generator.java

License:Apache License

protected boolean addNotNullSimpleElement(final Element target, final String name, final Object value) {
    if (target == null || name == null || value == null) {
        return false;
    }/*from www. j av  a  2  s.c om*/

    final Element e = new Element(name);
    e.addContent(value.toString());
    target.addContent(e);

    return true;
}

From source file:com.rometools.opml.io.impl.OPML10Generator.java

License:Apache License

protected Element generateHead(final Opml opml) {
    final Element head = new Element("head");
    boolean hasHead = false;

    if (opml.getCreated() != null) {
        hasHead |= addNotNullSimpleElement(head, "dateCreated",
                DateParser.formatRFC822(opml.getCreated(), Locale.US));
    }/*from   w  w w  .  j av  a  2 s.c  o  m*/

    hasHead |= addNotNullSimpleElement(head, "expansionState", intArrayToCsvString(opml.getExpansionState()));

    if (opml.getModified() != null) {
        hasHead |= addNotNullSimpleElement(head, "dateModified",
                DateParser.formatRFC822(opml.getModified(), Locale.US));
    }

    hasHead |= addNotNullSimpleElement(head, "ownerEmail", opml.getOwnerEmail());
    hasHead |= addNotNullSimpleElement(head, "ownerName", opml.getOwnerName());
    hasHead |= addNotNullSimpleElement(head, "title", opml.getTitle());
    hasHead |= addNotNullSimpleElement(head, "vertScrollState", opml.getVerticalScrollState());
    hasHead |= addNotNullSimpleElement(head, "windowBottom", opml.getWindowBottom());
    hasHead |= addNotNullSimpleElement(head, "windowLeft", opml.getWindowLeft());
    hasHead |= addNotNullSimpleElement(head, "windowRight", opml.getWindowRight());
    hasHead |= addNotNullSimpleElement(head, "windowTop", opml.getWindowTop());

    if (hasHead) {
        return head;
    } else {
        return null;
    }
}