Example usage for org.jdom2 Element addContent

List of usage examples for org.jdom2 Element addContent

Introduction

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

Prototype

@Override
public Element addContent(final Collection<? extends Content> newContent) 

Source Link

Document

Appends all children in the given collection to the end of the content list.

Usage

From source file:com.tactfactory.harmony.platform.winphone.updater.XmlProjectWinphone.java

License:Open Source License

public void addCompileFile(String filename, String depends) {
    final Element newNode = new Element(XML_ELEMENT_COMPILE);

    newNode.setAttribute(XML_ATTRIBUT_INCLUDE, filename);

    if (depends != null) {
        Element childDepends = new Element(XML_ELEMENT_DEPENDENT);
        childDepends.addContent(depends);
        newNode.addContent(childDepends);
    }// w w w.  j  a v  a  2  s.com

    Element itemGroup = this.findFirstItemGroup(XML_ELEMENT_COMPILE);

    this.removeIfExists(itemGroup, XML_ELEMENT_COMPILE, filename);
    itemGroup.addContent(newNode);
}

From source file:com.tactfactory.harmony.platform.winphone.updater.XmlProjectWinphone.java

License:Open Source License

public void addApplicationDefinitionFile(String filename) {
    final Element newNode = new Element(XML_ELEMENT_APPLICATION);

    newNode.setAttribute(XML_ATTRIBUT_INCLUDE, filename);

    Element subtype = new Element(XML_ELEMENT_SUBTYPE);
    subtype.setText(XML_CONTENT_DESIGNER);
    Element generator = new Element(XML_ELEMENT_GENERATOR);
    generator.setText(XML_CONTENT_MSBUILD_COMPILE);

    newNode.addContent(subtype);
    newNode.addContent(generator);//  w w w .j a v  a 2  s  .  c o  m

    Element itemGroup = this.findFirstItemGroup(XML_ELEMENT_APPLICATION);

    this.removeIfExists(itemGroup, XML_ELEMENT_APPLICATION, filename);
    itemGroup.addContent(newNode);
}

From source file:com.tactfactory.harmony.platform.winphone.updater.XmlProjectWinphone.java

License:Open Source License

public void addPageFile(String filename) {
    final Element newNode = new Element(XML_ELEMENT_PAGE);

    newNode.setAttribute(XML_ATTRIBUT_INCLUDE, filename);

    Element subtype = new Element(XML_ELEMENT_SUBTYPE);
    subtype.setText(XML_CONTENT_DESIGNER);
    Element generator = new Element(XML_ELEMENT_GENERATOR);
    generator.setText(XML_CONTENT_MSBUILD_COMPILE);

    newNode.addContent(subtype);
    newNode.addContent(generator);//w w w.  j  av  a 2s.  co  m

    Element itemGroup = this.findFirstItemGroup(XML_ELEMENT_PAGE);

    this.removeIfExists(itemGroup, XML_ELEMENT_PAGE, filename);
    itemGroup.addContent(newNode);
}

From source file:com.tactfactory.harmony.platform.winphone.updater.XmlProjectWinphone.java

License:Open Source License

public void addNoneFile(String filename) {
    final Element newNode = new Element(XML_ELEMENT_NONE);

    newNode.setAttribute(XML_ATTRIBUT_INCLUDE, filename);

    Element itemGroup = this.findFirstItemGroup(XML_ELEMENT_NONE);

    this.removeIfExists(itemGroup, XML_ELEMENT_NONE, filename);
    itemGroup.addContent(newNode);
}

From source file:com.tactfactory.harmony.platform.winphone.updater.XmlProjectWinphone.java

License:Open Source License

public void addContentFile(String filename) {
    final Element newNode = new Element(XML_ELEMENT_CONTENT);

    newNode.setAttribute(XML_ATTRIBUT_INCLUDE, filename);

    Element itemGroup = this.findFirstItemGroup(XML_ELEMENT_CONTENT);

    this.removeIfExists(itemGroup, XML_ELEMENT_CONTENT, filename);
    itemGroup.addContent(newNode);
}

From source file:com.tactfactory.harmony.platform.winphone.updater.XmlProjectWinphone.java

License:Open Source License

public void addEmbeddedFile(String filename) {
    final Element newNode = new Element(XML_ELEMENT_EMBEDDED);

    newNode.setAttribute(XML_ATTRIBUT_INCLUDE, filename);

    Element itemGroup = this.findFirstItemGroup(XML_ELEMENT_EMBEDDED);

    this.removeIfExists(itemGroup, XML_ELEMENT_EMBEDDED, filename);
    itemGroup.addContent(newNode);
}

From source file:com.tactfactory.harmony.utils.XMLUtils.java

License:Open Source License

/**
 * Add a node to the XML node if it doesn't contains it already.
 * @param newNode The node to add/*from ww w . java2  s . c  om*/
 * @param id The attribute name to compare
 * @param baseNode The node to add the new node to.
 * @return True if the node was added successfully.
 * False if the node already exists before.
 */
public static boolean addValue(final Element newNode, final String id, final Element baseNode) {

    Element findElement = null;

    // Debug Log
    ConsoleUtils.displayDebug("Update String : " + newNode.getAttributeValue(id));

    findElement = findNode(baseNode, newNode, id);

    // If not found Node, create it
    if (findElement == null) {
        baseNode.addContent(newNode);
        return true;
    } else {
        newNode.setText(findElement.getText());
        return false;
    }
}

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

License:Apache License

public String toXmlPartial(Object domainObject) {
    bombIf(!isAnnotationPresent(domainObject.getClass(), ConfigTag.class),
            "Object " + domainObject + " does not have a ConfigTag");
    Element element = elementFor(domainObject.getClass(), configCache);
    write(domainObject, element, configCache, registry);
    if (isAnnotationPresent(domainObject.getClass(), ConfigCollection.class)
            && domainObject instanceof Collection) {
        for (Object item : (Collection) domainObject) {
            if (isAnnotationPresent(item.getClass(), ConfigCollection.class) && item instanceof Collection) {
                new ExplicitCollectionXmlFieldWithValue(domainObject.getClass(), null, (Collection) item,
                        configCache, registry).populate(element);
                continue;
            }/*from w  ww . j  a va2  s. c om*/
            Element childElement = elementFor(item.getClass(), configCache);
            element.addContent(childElement);
            write(item, childElement, configCache, registry);
        }
    }

    try {
        ByteArrayOutputStream output = new ByteArrayOutputStream();
        XmlUtils.writeXml(element, output);
        return output.toString();
    } catch (IOException e) {
        throw bomb("Unable to write xml to String");
    }
}

From source file:com.thoughtworks.go.domain.activity.ProjectStatus.java

License:Apache License

private void addBreakers(Element element) {
    Element messages = new Element("messages");
    Element message = new Element("message");
    String breakerNames = StringUtils.join(breakers, ", ");
    message.setAttribute("text", breakerNames);
    message.setAttribute("kind", "Breakers");
    messages.addContent(message);
    element.addContent(messages);/*from  w w w . jav a  2s. com*/
}

From source file:com.thoughtworks.xstream.io.xml.JDom2Writer.java

License:Open Source License

protected Object createNode(final String name) {
    final Element element = documentFactory.element(encodeNode(name));
    final Element parent = top();
    if (parent != null) {
        parent.addContent(element);
    }/*from  w  w  w. j a  va  2s .  c o  m*/
    return element;
}