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.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 w  w w  .  j  a  va  2s . co  m*/
}

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  www.  j  a v  a2  s .c o m*/
}

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  ww  w. j  a v a2s .  c o  m*/
}

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

License:Open Source License

private Element findFirstItemGroup(String groupType) {
    Element result = null;//from w  ww  .  j a  va 2  s .c  o m

    Filter<Element> filter = new ElementFilter(XML_ELEMENT_ITEM);
    List<Element> content = this.rootNode.getContent(filter);

    filter = new ElementFilter(groupType);

    for (Element element : content) {
        content = element.getContent(filter);

        if (!content.isEmpty()) {
            result = element;
            break;
        }
    }

    if (result == null) {
        result = new Element(XML_ELEMENT_ITEM);
        filter = new ElementFilter("Import");
        content = this.rootNode.getContent(filter);
        rootNode.addContent(rootNode.indexOf(content.get(0)), result);
    }

    return result;
}

From source file:com.tactfactory.harmony.updater.impl.XmlAndroid.java

License:Open Source License

@Override
public void open(String file) {
    this.file = file;

    if (TactFileUtils.exists(file)) {
        this.doc = XMLUtils.openXMLFile(file);
    } else {//from w  w w .  j  a v a  2 s  .  co m
        Element rootElement = new Element("resources");
        this.doc = new Document(rootElement);
    }

    // Load Root element
    this.rootNode = doc.getRootElement();

    // Load Name space (required for manipulate attributes)
    this.namespace = rootNode.getNamespace("android");
}

From source file:com.tactfactory.harmony.updater.impl.XmlAndroid.java

License:Open Source License

@Override
public String addElement(String key, String value) {
    String result = value;/*from   w w  w.java  2 s.  c  om*/

    final Element newNode = new Element(XML_ELEMENT_STRING);

    // Add name to element
    newNode.setAttribute(XML_ELEMENT_NAME, key, this.namespace);

    // Set values
    newNode.setText(value);

    // If not found Node, create it
    if (!XMLUtils.addValue(newNode, XML_ELEMENT_NAME, rootNode)) {
        result = newNode.getText();
    }

    return result;
}

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

License:Apache License

private Document createEmptyCruiseConfigDocument() {
    Element root = new Element("cruise");
    Namespace xsiNamespace = Namespace.getNamespace("xsi", XML_NS);
    root.addNamespaceDeclaration(xsiNamespace);
    registry.registerNamespacesInto(root);
    root.setAttribute("noNamespaceSchemaLocation", "cruise-config.xsd", xsiNamespace);
    String xsds = registry.xsds();
    if (!xsds.isEmpty()) {
        root.setAttribute("schemaLocation", xsds, xsiNamespace);
    }/*from  ww  w  .j  av a2  s  . c  o  m*/
    root.setAttribute("schemaVersion", Integer.toString(GoConstants.CONFIG_SCHEMA_VERSION));
    return new Document(root);
}

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

License:Apache License

public Element ccTrayXmlElement(String fullContextPath) {
    Element element = new Element("Project");
    element.setAttribute("name", name);
    element.setAttribute("activity", activity);
    element.setAttribute("lastBuildStatus", lastBuildStatus);
    element.setAttribute("lastBuildLabel", lastBuildLabel);
    element.setAttribute("lastBuildTime", DateUtils.formatIso8601ForCCTray(lastBuildTime));
    element.setAttribute("webUrl", fullContextPath + "/" + webUrl);

    if (!breakers.isEmpty()) {
        addBreakers(element);/*from  w  ww . ja  v  a2s .  c o  m*/
    }

    return element;
}

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);//from ww w . ja v  a2s. c om
    element.addContent(messages);
}