Example usage for org.jdom2 Element setName

List of usage examples for org.jdom2 Element setName

Introduction

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

Prototype

public Element setName(final String name) 

Source Link

Document

Sets the (local) name of the element.

Usage

From source file:delfos.io.xml.rs.RecommenderSystemXML.java

License:Open Source License

/**
 * Devuelve el elemento que describe totalmente el sistema de recomendacin,
 * almacenando tambin los parmetros que posee y su valor
 *
 * @param rs Sistema de recomendacin a almacenar
 * @return Objeto XML que lo describe/*from w ww .ja va2  s.  c o  m*/
 */
public static Element getElement(GenericRecommenderSystem<? extends Object> rs) {
    Element element = ParameterOwnerXML.getElement(rs);
    element.setName(ELEMENT_NAME);
    return element;
}

From source file:delfos.io.xml.validationtechnique.ValidationTechniqueXML.java

License:Open Source License

public static Element getElement(ValidationTechnique validationTechnique) {
    Element element = ParameterOwnerXML.getElement(validationTechnique);
    element.setName(ELEMENT_NAME);
    return element;
}

From source file:docubricks.data.Brick.java

public Element toXML(File basepath) throws IOException {
    Element eroot = new Element("brick");
    eroot.setAttribute("id", "" + id);

    //kicking out <description> - no need for one more section

    eroot.addContent(elWithContent("name", name));
    eroot.addContent(elWithContent("abstract", vabstract));
    eroot.addContent(elWithContent("long_description", longdesc));
    eroot.addContent(elWithContent("notes", notes));
    eroot.addContent(elWithContent("license", license)); //Note: done very differently in spec!

    eroot.addContent(media.toXML(basepath));

    eroot.addContent(asmInstruction.toXML(basepath));
    for (Author a : authors)
        if (a != null) {
            Element e = new Element("author");
            e.setAttribute("id", a.id);
            eroot.addContent(e);//  w w  w .jav  a2 s.  c  om
        }
    for (Function p : functions)
        if (p != null)
            eroot.addContent(p.toXML(basepath));

    for (StepByStepInstruction instr : instructions) {
        Element e = instr.toXML(basepath);
        e.setName("instruction");
        //EEEEW!
        e.setAttribute("name", instr.name);
        eroot.addContent(e);
    }

    return eroot;
}

From source file:egovframework.rte.fdl.xml.AbstractXMLUtility.java

License:Apache License

/**
 * /*from  ww w.  j a  v  a2s  .  c o  m*/
 * 
 * @param element - ? Element
 * @param oldNode -  
 * @param newNodename -  
 */
public void chgNode(Element element, String oldNode, String newNodename) {
    List<?> list = element.getChildren();
    if (list.size() != 0) {
        for (int i = 0; i < list.size(); i++) {
            Element tmp = (Element) list.get(i);
            if (element.getName().equals(oldNode)) {
                element.setName(newNodename);
            } else {
                chgNode(tmp, oldNode, newNodename);
            }
        }
    } else {
        // Visit the children
        //   logger.debug("element Name:"+element.getName());
        if (element.getName().equals(oldNode)) {
            element.setName(newNodename);
        }
    }

}

From source file:es.ucm.fdi.ac.SourceSet.java

License:Open Source License

public Element saveToXML() throws IOException {
    Element sourcesElement = new Element("sources");

    // Create and add roots node
    Hasher h = new Hasher();
    Element rootsElement = new Element("roots");
    for (FileTreeNode sourceRoot : sourceRoots) {
        // Create node
        Element rootElement = new Element("root");
        rootElement.setAttribute("path", sourceRoot.toString());
        rootElement.setAttribute("sha1", h.showBytes(h.hash(sourceRoot.getFile()).getSha1()));

        // Add node
        rootsElement.addContent(rootElement);
    }//from  w  w w.j  a va 2 s.c om
    sourcesElement.addContent(rootsElement);

    Element mainFilterElement;
    // Create and add rootFilter node
    Element rootFilterElement = new Element("rootFilter");
    mainFilterElement = rootFilter.saveToXML();
    mainFilterElement.setName("filter");
    rootFilterElement.addContent(mainFilterElement);
    sourcesElement.addContent(rootFilterElement);

    // Create and add fileFilter node
    Element fileFilterElement = new Element("fileFilter");
    mainFilterElement = sourceFilter.saveToXML();
    mainFilterElement.setName("filter");
    fileFilterElement.addContent(mainFilterElement);
    sourcesElement.addContent(fileFilterElement);

    return sourcesElement;
}

From source file:es.upm.dit.xsdinferencer.extraction.extractorImpl.JSONTypesExtractorImpl.java

License:Apache License

/**
 * This method undoes what addPrefixToJSONKeysEndingsRecursive method did at the original JSON: It looks 
 * for elements whose name ends at a desired key ending preceeded by a prefix to remove and removes it.
 * @param rootElement the root element./* w  w  w .j  ava2 s . c om*/
 * @param desiredKeyEnding the desired ending.
 * @param prefixToRemove the prefix to remove.
 */
private void removePrefixToElementNameEndings(Element rootElement, String desiredKeyEnding,
        String prefixToRemove) {
    String keyToSearch = prefixToRemove + desiredKeyEnding;
    for (Element element : rootElement.getDescendants(Filters.element())) {
        if (!(element.getName().endsWith(keyToSearch)
                && element.getNamespace().equals(Namespace.NO_NAMESPACE))) {
            continue;
        }
        String name = element.getName();
        String newName = name.replaceAll(Pattern.quote(keyToSearch) + "$", desiredKeyEnding);
        element.setName(newName);
    }
}

From source file:neon.editor.resources.IContainer.java

License:Open Source License

public Element toElement() {
    Element container = super.toElement();
    container.setName("container");
    for (IObject io : contents) {
        Element item = new Element("item");
        item.setAttribute("id", io.resource.id);
        item.setAttribute("uid", Integer.toString(io.uid));
        container.addContent(item);/*from  w ww .  ja v a2s  .c  o m*/
    }
    // lock
    if (lock > 0) {
        container.setAttribute("lock", Integer.toString(lock));
        if (key != null) {
            container.setAttribute("key", key.id);
        }
    }
    // trap
    if (trap > 0) {
        container.setAttribute("trap", Integer.toString(trap));
        if (spell != null) {
            container.setAttribute("spell", spell.id);
        }
    }
    return container;
}

From source file:neon.editor.resources.IDoor.java

License:Open Source License

public Element toElement() {
    Element door = super.toElement();
    door.setName("door");
    door.setAttribute("state", state.toString());

    // bestemming
    Element dest = new Element("dest");
    if (text != null) {
        dest.setAttribute("sign", text);
    }/*from w ww.ja v  a 2s .co m*/
    if (destTheme != null) {
        door.addContent(dest);
        dest.setAttribute("theme", destTheme.id);
    } else if (destPos != null || destZone != null || destMap != null) {
        door.addContent(dest);
        if (destPos != null) {
            dest.setAttribute("x", Integer.toString(destPos.x));
            dest.setAttribute("y", Integer.toString(destPos.y));
        }
        if (destZone != null) {
            dest.setAttribute("z", Integer.toString(destZone.map.getZone(destZone)));
        }
        if (destMap != null) {
            dest.setAttribute("map", Integer.toString(destMap.uid));
        }
    }

    // lock
    if (lock > 0) {
        door.setAttribute("lock", Integer.toString(lock));
        if (key != null) {
            door.setAttribute("key", key.id);
        }
    }

    // trap
    if (trap > 0) {
        door.setAttribute("trap", Integer.toString(trap));
        if (spell != null) {
            door.setAttribute("spell", spell.id);
        }
    }

    return door;
}

From source file:net.instantcom.mm7.SubmitReq.java

License:Open Source License

public Element save(Element parent) {
    Element e = super.save(parent);
    e.setName("SubmitReq");
    if (!recipients.isEmpty()) {
        Element r = new Element("Recipients", e.getNamespace());
        addRecipients(r, RecipientType.TO);
        addRecipients(r, RecipientType.CC);
        addRecipients(r, RecipientType.BCC);
        if (r.getContentSize() > 0) {
            e.addContent(r);/*from w  w w  .  j  a  va  2s  . c o m*/
        }
    }
    if (serviceCode != null) {
        e.addContent(new Element("ServiceCode", e.getNamespace()).setText(serviceCode));
    }
    if (linkedId != null) {
        e.addContent(new Element("LinkedID", e.getNamespace()).setText(linkedId));
    }
    if (messageClass != null) {
        e.addContent(new Element("MessageClass", e.getNamespace()).setText(messageClass.toString()));
    }
    if (timeStamp != null) {
        e.addContent(
                new Element("TimeStamp", e.getNamespace()).setText(new RelativeDate(timeStamp).toString()));
    }
    if (replyChargingSize != null) {
        e.addContent(new Element("ReplyChargingSize", e.getNamespace()).setText(replyChargingSize.toString()));
    }
    if (replyDeadline != null) {
        e.addContent(new Element("ReplyDeadline", e.getNamespace()).setText(replyDeadline.toString()));
    }
    if (earlistDeliveryTime != null) {
        e.addContent(
                new Element("EarlistDeliveryTime", e.getNamespace()).setText(earlistDeliveryTime.toString()));
    }
    if (expiryDate != null) {
        e.addContent(new Element("ExpiryDate", e.getNamespace()).setText(expiryDate.toString()));
    }
    if (deliveryReport != null) {
        e.addContent(
                new Element("DeliveryReport", e.getNamespace()).setText(deliveryReport ? "True" : "False"));
    }
    if (readReply != null) {
        e.addContent(new Element("ReadReply", e.getNamespace()).setText(readReply ? "True" : "False"));
    }
    if (priority != null) {
        e.addContent(new Element("Priority", e.getNamespace()).setText(priority.toString()));
    }
    if (subject != null) {
        e.addContent(new Element("Subject", e.getNamespace()).setText(subject.toString()));
    }
    if (chargedParty != null) {
        e.addContent(new Element("ChargedParty", e.getNamespace()).setText(chargedParty.toString()));
    }
    if (chargedPartyId != null) {
        e.addContent(new Element("ChargedPartyID", e.getNamespace()).setText(chargedPartyId.toString()));
    }
    if (distributionIndicator != null) {
        e.addContent(new Element("DistributionIndicator", e.getNamespace())
                .setText(distributionIndicator ? "True" : "False"));
    }

    // deliveryCondition
    if (applicID != null) {
        e.addContent(new Element("ApplicID", e.getNamespace()).setText(applicID));
    }
    if (replyApplicID != null) {
        e.addContent(new Element("ReplyApplicID", e.getNamespace()).setText(replyApplicID));
    }
    if (auxApplicId != null) {
        e.addContent(new Element("AuxApplicId", e.getNamespace()).setText(auxApplicId));
    }
    if (contentClass != null) {
        e.addContent(new Element("ContentClass", e.getNamespace()).setText(contentClass.toString()));
    }
    if (drmContent != null) {
        e.addContent(new Element("DRMContent", e.getNamespace()).setText(drmContent ? "True" : "False"));
    }
    if (content != null) {
        Element c = new Element("Content", e.getNamespace());
        if (allowAdaptations != null) {
            c.setAttribute("allowAdaptations", allowAdaptations ? "True" : "False");
        }
        c.setAttribute("href", "cid:mm7-content");
        e.addContent(c);
    }

    return e;
}

From source file:org.artifactory.update.md.v125rc0.MdFileConverter.java

License:Open Source License

@Override
public void convert(Document doc) {
    Element rootElement = doc.getRootElement();
    rootElement.setName(getNewMetadataName());
    RepoPath repoPath = MetadataConverterUtils.extractRepoPath(rootElement);
    List<Element> toMove = MetadataConverterUtils.extractExtensionFields(rootElement);
    MetadataConverterUtils.addNewContent(rootElement, repoPath, toMove);
    // Not used anymore
    rootElement.removeChild(MdFolderConverter.ARTIFACTORY_NAME);
    rootElement.removeChild("xmlAware");
    rootElement.removeChild("downloadCount");
}