Example usage for org.dom4j Element elements

List of usage examples for org.dom4j Element elements

Introduction

In this page you can find the example usage for org.dom4j Element elements.

Prototype

List<Element> elements(QName qName);

Source Link

Document

Returns the elements contained in this element with the given fully qualified name.

Usage

From source file:com.ms.commons.test.datareader.impl.XmlReaderUtil.java

License:Open Source License

@SuppressWarnings("unchecked")
protected static MemoryRow readRow(Element rowE) {
    if (rowE == null)
        return null;
    List<Element> elements = rowE.elements("field");
    if (elements.isEmpty())
        return null;

    List<MemoryField> fieldList = new ArrayList<MemoryField>(elements.size());
    for (Element fieldE : elements) {
        fieldList.add(readField(fieldE));
    }/*from  ww w .  j  ava 2 s  .co m*/
    return new MemoryRow(fieldList);
}

From source file:com.nokia.helium.ant.data.MacroMeta.java

License:Open Source License

@SuppressWarnings("unchecked")
public List<String> getAttributes() {
    List<String> attributes = new ArrayList<String>();
    if (getNode().getNodeType() == Node.ELEMENT_NODE) {
        Element element = (Element) getNode();
        List<Element> attributeNodes = element.elements("attribute");
        for (Element attributeNode : attributeNodes) {
            attributes.add(attributeNode.attributeValue("name"));
        }// w  w w .  j  a  v  a  2  s .com
    }
    return attributes;
}

From source file:com.nokia.helium.ant.data.TaskMeta.java

License:Open Source License

@SuppressWarnings("unchecked")
public Map<String, String> getParams() {
    Map<String, String> params = new HashMap<String, String>();

    if (getNode().getNodeType() == Node.ELEMENT_NODE) {
        Element element = (Element) getNode();
        List<Element> paramNodes = element.elements("param");
        for (Element paramNode : paramNodes) {
            params.put(paramNode.attributeValue("name"), paramNode.attributeValue("value"));
        }//from w ww  .  ja  v a  2 s .c om
    }
    return params;
}

From source file:com.nokia.helium.antlint.checks.CheckAntCall.java

License:Open Source License

/**
 * Check against the given node./*  ww w  . ja  v a  2  s. c om*/
 * 
 * @param node is the node to check.
 */
@SuppressWarnings("unchecked")
private void checkAntCalls(Element node) {
    if (node.elements("antcall") != null) {
        List<Element> antcallList = node.elements("antcall");
        for (Element antcallElement : antcallList) {
            String antcallName = antcallElement.attributeValue("target");
            if (((node.elements("param") == null)
                    || (node.elements("param") != null && node.elements("param").isEmpty()))
                    && !checkTargetDependency(antcallName)) {
                log("<antcall> is used with no param elements and calls the target " + antcallName
                        + " that has no dependencies! (<runtarget> could be used instead.)");
            }
        }
    }
}

From source file:com.nokia.helium.antlint.checks.CheckPresetDefMacroDefName.java

License:Open Source License

/**
 * {@inheritDoc}//from ww w.j  av a  2  s.  c  o m
 */
@SuppressWarnings("unchecked")
public void run(Element node) {
    if (node.getName().equals("presetdef") || node.getName().equals("macrodef")) {
        String text = node.attributeValue("name");
        if (text != null && !text.isEmpty()) {
            checkDefName(text);
        }

        List<Element> attributeList = node.elements("attribute");
        for (Element attributeElement : attributeList) {
            String attributeName = attributeElement.attributeValue("name");
            checkDefName(attributeName);
        }
    }
}

From source file:com.nokia.helium.antlint.checks.CheckRunTarget.java

License:Open Source License

/**
 * Check against the given node./*from  ww  w. j a  v  a2 s . c o m*/
 * 
 * @param node
 *            is the node to check.
 */
@SuppressWarnings("unchecked")
private void checkRunTargets(Element node) {
    if (node.elements("runtarget") != null) {
        List<Element> runTargetList = node.elements("runtarget");
        for (Element runTargetElement : runTargetList) {
            String runTargetName = runTargetElement.attributeValue("target");
            if (checkTargetDependency(runTargetName)) {
                log("<runtarget> calls the target " + runTargetName + " that has dependencies!");
            }
        }
    }
}

From source file:com.npower.dm.hibernate.management.ModelManagementBeanImpl.java

License:Open Source License

/**
 * // ww w.jav  a  2  s  .  c om
 * <pre>
 * Import the TAC list of models form file.
 * &lt;pre&gt;
 * 
 * @param xmlFile
 * @throws DMException
 * 
 */
public void importModelTAC(File xmlFile) throws DMException {

    try {

        ManagementBeanFactory factory = this.getManagementBeanFactory();
        ModelBean modelBean = factory.createModelBean();
        factory.beginTransaction();

        SAXReader reader = new SAXReader();
        Document confDoc = reader.read(xmlFile);
        Element root = confDoc.getRootElement();

        for (Iterator<Element> i = root.elementIterator("Manufacturer"); i.hasNext();) {

            String manufacturerExternalID = "";
            Element manElement = i.next();
            manufacturerExternalID = manElement.elementText("ExternalID");
            Manufacturer manufacturerBean = modelBean.getManufacturerByExternalID(manufacturerExternalID);
            if (manufacturerBean == null) {
                System.err.println("Could not find this manufacturer: " + manufacturerExternalID);
                continue;
            }

            for (Iterator<Element> j = manElement.elementIterator("Model"); j.hasNext();) {
                String modelExternalID = "";
                Element modelElement = j.next();
                modelExternalID = modelElement.elementText("ExternalID");
                Model model = modelBean.getModelByManufacturerModelID(manufacturerBean, modelExternalID);
                if (model == null) {
                    System.err.println("Could not find this model: " + modelExternalID);
                    continue;
                }

                List<Element> TACsList = modelElement.elements("TACs");
                List<String> TACInfos = new ArrayList<String>();
                for (int k = 0; k < TACsList.size(); k++) {
                    List<Element> TACList = ((TACsList.get(k))).elements("TAC");
                    for (int m = 0; m < TACList.size(); m++) {
                        Element tacElement = TACList.get(m);
                        String tac = tacElement.getText();
                        if (StringUtils.isNotEmpty(tac) && tac.length() >= 8) {
                            TACInfos.add(tac);
                        }
                    }

                }
                modelBean.update(model);
                modelBean.setTACInfos(model, TACInfos);
            }
        }
        factory.commit();
    } catch (Exception ex) {
        ex.printStackTrace();
    }

}

From source file:com.olympum.tools.CsJniNetWrapperGenerator.java

License:Open Source License

private void emitConstants(PrintStream out, Element clazz) {
    List constants = clazz.elements("constant");
    Iterator iter = constants.iterator();
    while (iter.hasNext()) {
        Element e = (Element) iter.next();
        emitConstant(out, e);/* w  ww.  j  a v a 2s. c  om*/
    }
}

From source file:com.olympum.tools.CsJniNetWrapperGenerator.java

License:Open Source License

private void emitCtorAndMethodIds(PrintStream out, Element clazz, String className, boolean isImplementation) {
    List ctors = clazz.elements("constructor");
    if (!isImplementation) {
        for (int i = 0; i < ctors.size(); i++) {
            Element e = (Element) ctors.get(i);
            emitIndented(out, "readonly static JConstructor ctor" + i + ";", 2);
        }/*from ww w. j a  v  a  2 s  .co  m*/
    }

    List methods = clazz.elements("method");
    for (int i = 0; i < methods.size(); i++) {
        Element e = (Element) methods.get(i);
        boolean isAbstract = e.attributeValue("abstract") != null;
        if (!isImplementation || (isImplementation && isAbstract)) {
            out.println("\t\treadonly static JMethod " + e.attributeValue("name") + "_mid" + i + ";");
        }
    }
    out.println();

    emitIndented(out, "static " + className + "() {", 2);
    String qualifiedName = clazz.attributeValue("name").replace('.', '/');
    emitIndented(out, "clazz = JClass.ForName(\"" + qualifiedName + "\");", 3);

    if (!isImplementation) {
        for (int i = 0; i < ctors.size(); i++) {
            Element e = (Element) ctors.get(i);
            String ctrSignature = getCtorSignature(e);
            emitIndented(out, "ctor" + i + " = clazz.GetConstructor(" + "\"" + ctrSignature + "\");", 3);
            /*
            * Force the creation of the implicit operators between
            * java.lang.String and System.String
            */
            if ("java/lang/String".equals(qualifiedName) && "([C)V".equals(ctrSignature))
                ctrIndex = i;
        }
    }

    for (int i = 0; i < methods.size(); i++) {
        Element e = (Element) methods.get(i);
        boolean isAbstract = e.attributeValue("abstract") != null;
        if (isImplementation && !isAbstract)
            continue;
        String methodName = e.attributeValue("name");
        boolean isStatic = e.attributeValue("static") != null;
        String callString = isStatic ? "GetStaticMethod" : "GetMethod";
        emitIndented(out, methodName + "_mid" + i + " = clazz." + callString + "(\"" + methodName + "\", \""
                + getMethodSignature(e) + "\");", 3);
    }
    emitIndented(out, "}", 2);
    out.println();
}

From source file:com.olympum.tools.CsJniNetWrapperGenerator.java

License:Open Source License

private void emitCtors(PrintStream out, Element clazz, String className) {
    List ctors = clazz.elements("constructor");
    for (int i = 0; i < ctors.size(); i++) {
        Element e = (Element) ctors.get(i);
        emitCtor(out, className, e, i);//from   w w w  . j a  v a2  s  .  c o  m
    }
}