Example usage for org.jdom2 Attribute getName

List of usage examples for org.jdom2 Attribute getName

Introduction

In this page you can find the example usage for org.jdom2 Attribute getName.

Prototype

public String getName() 

Source Link

Document

This will retrieve the local name of the Attribute.

Usage

From source file:org.yawlfoundation.yawl.resourcing.util.DataSchemaBuilder.java

License:Open Source License

/**
 * Clones a set of attributes. Needs to be done this way to (i) break the
 * parental attachment to the attribute; and (ii) to fix any errant namespace
 * prefixes//from  w  w w.j a  v a  2  s  .  c o  m
 * @param element the element with the attributes to clone
 * @param defNS the default namespace
 * @return the List of clone attributes
 */
private List<Attribute> cloneAttributes(Element element, Namespace defNS) {
    String prefix = element.getNamespacePrefix();
    List<Attribute> cloned = new ArrayList<Attribute>();
    for (Attribute attribute : element.getAttributes()) {
        String value = getAttributeValue(attribute, prefix, defNS);
        Attribute copy = new Attribute(attribute.getName(), value);
        cloned.add(copy);
    }
    return cloned;
}

From source file:org.yawlfoundation.yawl.scheduling.util.Utils.java

License:Open Source License

public static String attribute2String(Attribute a) {
    if (a == null)
        return null;
    else//from w  w  w  .  ja v a  2s .co  m
        return a.getName() + "=" + a.getValue();
}

From source file:org.yawlfoundation.yawl.scheduling.util.XMLUtils.java

License:Open Source License

/**
 * merges content of two elements recursively into element minor following
 * content will be copied: Text, Element, Attribute if conflicts, minor will
 * be overwrite with content of major//from   w  w w . j  av a 2s .c om
 * 
 * @param minor
 * @param major
 */
public static boolean mergeElements(Element minor, Element major) throws Exception {
    // logger.debug("minor: " + Utils.element2String(minor, false));
    // logger.debug("major: " + Utils.element2String(major, false));
    boolean changed = false;
    if (minor == null) {
        minor = major;
        // logger.debug("set minor = " + Utils.element2String(major, false));
        changed = true;
    } else if (major != null) {
        if (!minor.getText().equals(major.getText())) {
            minor.setText(major.getText());
            // logger.debug("minor.setText("+major.getText()+")");
            changed = true;
        }

        for (Attribute a : (List<Attribute>) major.getAttributes()) {
            Attribute aCopy = (Attribute) Utils.deepCopy(a);
            if (minor.getAttribute(a.getName()) == null
                    || !minor.getAttributeValue(a.getName()).equals(a.getValue())) {
                minor.setAttribute(aCopy.detach());
                // logger.debug("minor.setAttribute("+Utils.toString(a)+")");
                changed = true;
            }
        }

        for (Element e : (List<Element>) major.getChildren()) {
            Element eCopy = (Element) Utils.deepCopy(e);
            List<Element> minorChildren = minor.getChildren(e.getName());
            // logger.debug("minorChildren: " + Utils.toString(minorChildren));
            // logger.debug("e: " + Utils.toString(e));
            Element firstInList = existInList(minorChildren, e);
            if (firstInList == null) {
                // logger.debug("minor.addContent: " +
                // Utils.toString(eCopy.detach()));
                minor = minor.addContent(eCopy.detach());
                // logger.debug("minor.addContent("+Utils.element2String(e,
                // false)+")");
                changed = true;
            } else {
                changed = mergeElements(firstInList, eCopy) || changed;
            }
        }
    }

    return changed;
}

From source file:org.yawlfoundation.yawl.unmarshal.YDecompositionParser.java

License:Open Source License

private YDecomposition createDecomposition(Element decompElem) {
    Namespace schemaInstanceNS = decompElem.getNamespace("xsi");
    String xsiType = _decompElem.getAttributeValue("type", schemaInstanceNS);
    String id = _decompElem.getAttributeValue("id");

    String elementName = _decompElem.getName();
    if ("NetFactsType".equals(xsiType) || "rootNet".equals(elementName)) {
        _decomposition = new YNet(id, _specificationParser.getSpecification());
        parseNet((YNet) _decomposition, decompElem);
    } else if ("WebServiceGatewayFactsType".equals(xsiType)) {
        _decomposition = new YAWLServiceGateway(id, _specificationParser.getSpecification());
        parseWebServiceGateway((YAWLServiceGateway) _decomposition, decompElem);
    }//from  w w  w  . j ava  2  s . com
    /**
     * AJH: Added to support XML attribute pass-thru from specification into task output data doclet.
     * Load element attributes
     */
    for (Attribute attr : decompElem.getAttributes()) {
        String attname = attr.getName();
        boolean isXsiNS = attr.getNamespace() == schemaInstanceNS;

        //don't add the standard YAWL schema attributes to the pass through list.
        if (!("id".equals(attname) || ("type".equals(attname) && isXsiNS))) {
            String value = attr.getValue();
            if (value.startsWith("dynamic{")) {
                _decomposition.setAttribute(attr.getName(), new DynamicValue(value, _decomposition));
            } else
                _decomposition.setAttribute(attr.getName(), value);
        }
    }

    parseDecompositionRoles(_decomposition, decompElem);
    _decomposition.setLogPredicate(parseLogPredicate(decompElem, _yawlNS));

    // added for resourcing
    parseExternalInteraction(_decomposition, decompElem);
    parseCodelet(_decomposition, decompElem);

    return _decomposition;
}

From source file:projetxml.model.DownloadOmdb.java

/**
 * return map about Omdb information//from w ww  .ja  v a 2 s  .  com
 * @return map about Omdb information
 * @throws JDOMException
 * @throws IOException
 */
public Map<String, String> getInfos() throws JDOMException, IOException {
    //Rcupration de la liste des attributs
    Map<String, String> informations = new HashMap<>();
    //On creer un fichier qui sert de relai pour stocker
    //temporairement les informations
    //C'est plus simple comme a
    File f = new File("intermediaire.xml");
    //Ajout du string
    //Conversion sous la forme d'un xml
    try {
        FileWriter fw = new FileWriter(f);
        BufferedWriter output = new BufferedWriter(fw);
        output.write(this.infos);
        output.flush();
        output.close();
    } catch (IOException e) {
    }
    //Rcupration de la balise movie
    Document document = new SAXBuilder().build(f);
    //Il se peut que l'url ne contienne pas de "movie"
    //Il va donc lever une exception
    //On l'attrape donc pour eviter que l'appli plante
    try {
        Element movie = document.getRootElement().getChild("movie");
        for (Attribute a : movie.getAttributes()) {
            informations.put(a.getName(), a.getValue());
        }
    } catch (Exception e) {
    }
    //Suppresion du file
    f.delete();
    //Rcupration de tous les attributs sous la forme d'une map        
    return informations;
}

From source file:qtiscoringengine.CustomOperatorRegistry.java

License:Open Source License

private static String getOperatorType(Element customOperatorNode) {
    for (Attribute attribute : customOperatorNode.getAttributes()) {
        if ("CLASS".equalsIgnoreCase(attribute.getName())) {
            return attribute.getValue();
        }/*from   ww  w . j a va2 s.com*/
    }
    return "";
}

From source file:qtiscoringengine.ISECustomExpression.java

License:Open Source License

private static String getOperatorType(Element customOperatorNode) {
    for (Attribute attribute : customOperatorNode.getAttributes()) {
        if (StringUtils.equalsIgnoreCase(attribute.getName(), "CLASS")) {
            return attribute.getValue();
        }//  w w  w .j  av  a2 s.co m
    }
    return "";
}

From source file:recparser.idmef.IdmefParser.java

License:Open Source License

private void addAttribute(Element current, Attribute attribute, Object o) {

    String elemento = current.getName();
    String attributeName = attribute.getName();
    String attributeValue = attribute.getValue();

    if (elemento.equals("Target")) {
        if (attributeName.equals("ident")) {
            if (o instanceof IntrusionTarget) {
                IntrusionTarget target = (IntrusionTarget) o;
                target.setTargetID(attributeValue);
            }// w  ww. j  a  va 2 s  .c o m
        }
    } else if (elemento.equals("Source")) {
        if (o instanceof IntrusionSource) {
            IntrusionSource source = (IntrusionSource) o;
            if (attributeName.equals("spoofed")) {
                source.setSpoofed(attributeValue);

            } else if (attributeName.equals("ident")) {
                source.setIdent(attributeValue);

            } else if (attributeName.equals("interface")) {
                source.setInterfaceSource(attributeValue);
            }
        }
    } else if (elemento.equals("Address")) {
        if (o instanceof Address) {
            Address a = (Address) o;
            if (attributeName.equals("category")) {
                a.setCategory(attributeValue);

            } else if (attributeName.equals("vlan-name")) {
                a.setVlan_name(attributeValue);

            } else if (attributeName.equals("vlan-num")) {
                a.setVlan_num(attributeValue);

            } else if (attributeName.equals("ident")) {
                a.setIdent(attributeValue);
            }
        }
    } else if (elemento.equals("Service")) {
        if (o instanceof IntrusionTarget) {
            IntrusionTarget target = (IntrusionTarget) o;
            if (attributeName.equals("ident")) {
                target.setServiceID(attributeValue);
            }
        }
    }

}

From source file:ru.iteco.xmldoc.ConfigEx.java

License:Open Source License

public Map<String, String> getElementMap(Element el) {
    Map<String, String> result = new LinkedHashMap<String, String>();
    for (Attribute attr : el.getAttributes()) {
        if (attr.getName().equals("class"))
            //     ?  
            result.put("_class", attr.getValue());
        result.put(attr.getName(), attr.getValue());
    }//from w  w w .j a va2 s .c  om

    result.put("description", getPreviousComment(el));
    result.put("source", new XMLOutputter().outputString(el).trim());
    result.put("elementname", el.getName());

    return result;
}

From source file:ru.iteco.xmldoc.Scope.java

License:Open Source License

public Scope(Element element) {
    Element scopeEl = element.getParentElement();
    if (scopeEl.getName() != "scope")
        System.out.println("Where is scope ? Parent el :" + scopeEl.getName());
    else {//from  w w  w  . j a v a2s  .c o  m
        List<Attribute> scopes = scopeEl.getAttributes();
        for (Attribute sc : scopes) {
            String tmp_val = sc.getValue();
            String[] tmp_vals = tmp_val.split(",");
            for (String v : tmp_vals) {
                add(sc.getName(), v.trim());
            }
        }
    }
}