Example usage for org.dom4j Element attributeValue

List of usage examples for org.dom4j Element attributeValue

Introduction

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

Prototype

String attributeValue(QName qName);

Source Link

Document

This returns the attribute value for the attribute with the given fully qualified name or null if there is no such attribute or the empty string if the attribute value is empty.

Usage

From source file:au.gov.ansto.bragg.process.parse.Parse.java

License:Open Source License

public static String getAttribute(Element item, String name) {
    String value = "null";
    if (item.attributeValue(name) != null)
        value = item.attributeValue(name);
    return value;
}

From source file:au.gov.ansto.bragg.process.parse.Parse.java

License:Open Source License

public static FrameworkConfiguration parseFile(Element rootElement)
        throws NullConfigurationPointerException, DocumentException {
    String frameworkName = rootElement.attributeValue("name");
    FrameworkConfiguration framework = new FrameworkConfiguration_(frameworkName);
    //      List<?> list = rootElement.selectNodes("*");
    //      String groupName;
    //      int numberOfAttribute;
    for (Iterator<?> iter = rootElement.elementIterator("source"); iter.hasNext();) {
        //         for (Iterator<?> iter = list.iterator(); iter.hasNext();){
        Element item = (Element) iter.next();
        //         System.out.println(item.toString());
        //         groupName = item.getName().toString();
        SourceConfiguration sourceConfiguration = getSourceConfiguration(item, frameworkName);
        framework.addSourceConfiguration(sourceConfiguration);
    }/* w  w  w. j  ava  2 s.c om*/

    for (Iterator<?> iter = rootElement.elementIterator("sink"); iter.hasNext();) {
        Element item = (Element) iter.next();
        SinkConfiguration sinkConfiguration = getSinkConfiguration(item, frameworkName);
        framework.addSinkConfiguration(sinkConfiguration);
    }
    for (Iterator<?> iter = rootElement.elementIterator("processor"); iter.hasNext();) {
        Element item = (Element) iter.next();
        ProcessorConfiguration processorConfiguration = getProcessorConfiguration(item, frameworkName);
        framework.addProcessorConfiguration(processorConfiguration);
    }
    for (Iterator<?> iter = rootElement.elementIterator("composite_processor"); iter.hasNext();) {
        Element item = (Element) iter.next();
        CompositeProcessorConfiguration processorConfiguration = getCompositeProcessorConfiguration(item,
                frameworkName);
        framework.addProcessorConfiguration(processorConfiguration);
    }
    for (Iterator<?> iter = rootElement.elementIterator("ins"); iter.hasNext();) {
        Element item = (Element) iter.next();
        framework.setInConfigurationList(getInConfigurationList(item, frameworkName));
    }
    for (Iterator<?> iter = rootElement.elementIterator("outs"); iter.hasNext();) {
        Element item = (Element) iter.next();
        framework.setOutConfigurationList(getOutConfigurationList(item, frameworkName));
    }
    for (Iterator<?> iter = rootElement.elementIterator("vars"); iter.hasNext();) {
        Element item = (Element) iter.next();
        framework.setVarConfigurationList(getVarConfigurationList(item, frameworkName));
    }
    for (Iterator<?> iter = rootElement.elementIterator("connectors"); iter.hasNext();) {
        Element item = (Element) iter.next();
        framework.setConnectorConfigurationList(getConnectorConfigurationList(item, frameworkName));
    }
    for (Iterator<?> iter = rootElement.elementIterator("agents"); iter.hasNext();) {
        Element item = (Element) iter.next();
        framework.setAgentConfigurationList(getAgentConfigurationList(item));
    }
    return framework;
}

From source file:au.gov.ansto.bragg.process.parse.Parse.java

License:Open Source License

protected static CompositeProcessorConfiguration getCompositeProcessorConfiguration(final Element item,
        final String frameworkName) throws NullConfigurationPointerException, DocumentException {
    //      int id = Integer.parseInt(item.attributeValue("id"));
    String name = item.attributeValue("name");
    String classType = item.attributeValue("class");
    CompositeProcessorConfiguration_ compositeProcessorConfiguration = new CompositeProcessorConfiguration_(
            name, frameworkName, classType);
    String version = item.attributeValue("version");
    if (version != null)
        compositeProcessorConfiguration.setVersionNumber(version);
    else/*from   w  ww. ja  v  a2 s . co m*/
        compositeProcessorConfiguration.setVersionNumber("0.0.0");
    //      List<?> list = item.selectNodes("*");
    //      String groupName;
    //      for (Iterator<?> iter = list.iterator(); iter.hasNext();){
    for (Iterator<?> iter = item.elementIterator("processor"); iter.hasNext();) {
        Element subItem = (Element) iter.next();
        //         System.out.println(subItem.toString());
        //         if (groupName == "processor"){
        ProcessorConfiguration processorConfiguration = getProcessorConfiguration(subItem, name);
        compositeProcessorConfiguration.addProcessorConfiguration(processorConfiguration);
    }
    for (Iterator<?> iter = item.elementIterator("composite_processor"); iter.hasNext();) {
        Element subItem = (Element) iter.next();
        CompositeProcessorConfiguration processorConfiguration = getCompositeProcessorConfiguration(subItem,
                name);
        compositeProcessorConfiguration.addProcessorConfiguration(processorConfiguration);
    }
    for (Iterator<?> iter = item.elementIterator("ins"); iter.hasNext();) {
        Element subItem = (Element) iter.next();
        compositeProcessorConfiguration.setInConfigurationList(getInConfigurationList(subItem, name));
    }
    for (Iterator<?> iter = item.elementIterator("outs"); iter.hasNext();) {
        Element subItem = (Element) iter.next();
        compositeProcessorConfiguration.setOutConfigurationList(getOutConfigurationList(subItem, name));
    }
    for (Iterator<?> iter = item.elementIterator("vars"); iter.hasNext();) {
        Element subItem = (Element) iter.next();
        compositeProcessorConfiguration.setVarConfigurationList(getVarConfigurationList(subItem, name));
    }
    for (Iterator<?> iter = item.elementIterator("connectors"); iter.hasNext();) {
        Element subItem = (Element) iter.next();
        compositeProcessorConfiguration
                .setConnectorConfigurationList(getConnectorConfigurationList(subItem, name));
    }
    return compositeProcessorConfiguration;
}

From source file:au.gov.ansto.bragg.process.parse.Parse.java

License:Open Source License

protected static SourceConfiguration getSourceConfiguration(final Element item, final String parentName)
        throws DocumentException {
    SourceConfiguration configuration = new SourceConfiguration_(item.attributeValue("name"), parentName,
            item.attributeValue("class"), item.attributeValue("method"));

    //      List<?> subList = item.selectNodes("*");
    //      String portsName = null;
    List<InConfiguration> inConfigurationList = new LinkedList<InConfiguration>();
    List<OutConfiguration> outConfigurationList = new LinkedList<OutConfiguration>();
    List<VarConfiguration> varConfigurationList = new LinkedList<VarConfiguration>();

    //      for (Iterator<?> subIter = subList.iterator(); subIter.hasNext();){
    for (Iterator<?> iter = item.elementIterator("ins"); iter.hasNext();) {
        Element subItem = (Element) iter.next();
        //         portsName = subItem.getName().toString();
        inConfigurationList = getInConfigurationList(subItem, configuration.getName());
    }/*from   ww  w. j a va2s . c  o m*/
    for (Iterator<?> iter = item.elementIterator("outs"); iter.hasNext();) {
        Element subItem = (Element) iter.next();
        outConfigurationList = getOutConfigurationList(subItem, configuration.getName());
    }
    for (Iterator<?> iter = item.elementIterator("vars"); iter.hasNext();) {
        Element subItem = (Element) iter.next();
        varConfigurationList = getVarConfigurationList(subItem, configuration.getName());
    }

    configuration.setInConfigurationList(inConfigurationList);
    configuration.setOutConfigurationList(outConfigurationList);
    configuration.setVarConfigurationList(varConfigurationList);
    //      System.out.println(configuration.toString());
    return configuration;
}

From source file:au.gov.ansto.bragg.process.parse.Parse.java

License:Open Source License

protected static SinkConfiguration getSinkConfiguration(final Element item, final String parentName)
        throws DocumentException {
    String name = item.attributeValue("name");
    String autoPlot = item.attributeValue("autoplot");
    String isDefaultSink = item.attributeValue("defaultsink");
    SinkConfiguration configuration = new SinkConfiguration_(name, parentName, autoPlot, isDefaultSink);

    //      List<?> subList = item.selectNodes("*");
    //      String portsName = null;
    List<InConfiguration> inConfigurationList = new LinkedList<InConfiguration>();
    List<OutConfiguration> outConfigurationList = new LinkedList<OutConfiguration>();
    List<VarConfiguration> varConfigurationList = new LinkedList<VarConfiguration>();

    //      for (Iterator<?> subIter = subList.iterator(); subIter.hasNext();){
    for (Iterator<?> iter = item.elementIterator("ins"); iter.hasNext();) {
        Element subItem = (Element) iter.next();
        //         portsName = subItem.getName().toString();
        inConfigurationList = getInConfigurationList(subItem, name);
    }/*from   w ww  . j a  v  a 2 s . c om*/
    for (Iterator<?> iter = item.elementIterator("outs"); iter.hasNext();) {
        Element subItem = (Element) iter.next();
        outConfigurationList = getOutConfigurationList(subItem, name);
    }
    for (Iterator<?> iter = item.elementIterator("vars"); iter.hasNext();) {
        Element subItem = (Element) iter.next();
        varConfigurationList = getVarConfigurationList(subItem, name);
    }

    configuration.setInConfigurationList(inConfigurationList);
    configuration.setOutConfigurationList(outConfigurationList);
    configuration.setVarConfigurationList(varConfigurationList);
    //      System.out.println(configuration.toString());
    return configuration;
}

From source file:au.gov.ansto.bragg.process.parse.Parse.java

License:Open Source License

protected static ProcessorConfiguration getProcessorConfiguration(final Element item, final String parentName)
        throws DocumentException {
    String name = item.attributeValue("name");
    ProcessorConfiguration configuration = new ProcessorConfiguration_(name, parentName,
            item.attributeValue("class"), item.attributeValue("method"));
    String version = item.attributeValue("version");
    if (version != null)
        configuration.setVersionNumber(version);
    else/*from ww  w  . j a v a 2 s  . c o m*/
        configuration.setVersionNumber("0.0.0");
    //      List<?> subList = item.selectNodes("*");
    //      String portsName = null;
    List<InConfiguration> inConfigurationList = new LinkedList<InConfiguration>();
    List<OutConfiguration> outConfigurationList = new LinkedList<OutConfiguration>();
    List<VarConfiguration> varConfigurationList = new LinkedList<VarConfiguration>();

    //      for (Iterator<?> subIter = subList.iterator(); subIter.hasNext();){
    for (Iterator<?> iter = item.elementIterator("ins"); iter.hasNext();) {
        Element subItem = (Element) iter.next();
        //         portsName = subItem.getName().toString();
        inConfigurationList = getInConfigurationList(subItem, name);
    }
    for (Iterator<?> iter = item.elementIterator("outs"); iter.hasNext();) {
        Element subItem = (Element) iter.next();
        outConfigurationList = getOutConfigurationList(subItem, name);
    }
    for (Iterator<?> iter = item.elementIterator("vars"); iter.hasNext();) {
        Element subItem = (Element) iter.next();
        varConfigurationList = getVarConfigurationList(subItem, name);
    }

    configuration.setInConfigurationList(inConfigurationList);
    configuration.setOutConfigurationList(outConfigurationList);
    configuration.setVarConfigurationList(varConfigurationList);
    //      System.out.println(configuration.toString());
    return configuration;
}

From source file:au.gov.ansto.bragg.process.parse.Parse.java

License:Open Source License

protected static PortConfiguration getPortConfiguration(final Element element, final String patternName,
        final String parentName) throws DocumentException {
    PortConfiguration configuration = null;
    String name, type;//  w  w  w  . j  a v a  2 s . c o  m
    int dimension = 0;
    //      id = Integer.parseInt(element.attributeValue("id"));
    name = element.attributeValue("name");
    type = element.attributeValue("type");
    try {
        dimension = Integer.parseInt(element.attributeValue("dimension"));
    } catch (Exception ex) {
    }

    if (patternName == "in")
        configuration = new InConfiguration_(name, dimension, type, parentName);
    if (patternName == "out")
        configuration = new OutConfiguration_(name, dimension, type, parentName);
    if (patternName == "var") {
        String defaultValue = element.attributeValue("default_value");
        String label = element.attributeValue("label");
        //         System.out.println("var_" + id +": ");
        int ownerID = 0;
        if (element.attributeValue("owner") != null)
            ownerID = Integer.parseInt(element.attributeValue("owner"));
        String max = element.attributeValue("max");
        String min = element.attributeValue("min");
        String usage = element.attributeValue("usage");
        String options = element.attributeValue("option");
        String UIWidth = element.attributeValue("UIwidth");
        Map<String, String> attributeMap = new HashMap<String, String>();
        List<?> attributes = element.attributes();
        for (Object object : attributes) {
            if (object instanceof Attribute) {
                Attribute attribute = (Attribute) object;
                attributeMap.put(attribute.getName(), attribute.getStringValue());
            }
        }
        configuration = new VarConfiguration_(name, dimension, type, parentName, defaultValue, ownerID, max,
                min, usage, label, options, UIWidth, attributeMap);
    }
    return configuration;
}

From source file:au.gov.ansto.bragg.process.parse.Parse.java

License:Open Source License

protected static ConnectorConfiguration getConnectorConfiguration(final Element element,
        final String parentName) throws DocumentException {
    ConnectorConfiguration configuration = null;
    String name = "*connector*";
    //      int id;
    String producerID = null, consumerID = null;
    //      id = Integer.parseInt(element.attributeValue("id"));
    //      name = element.attributeValue("name");
    if (element.attributeValue("producer") != null)
        producerID = element.attributeValue("producer");
    if (element.attributeValue("consumer") != null)
        consumerID = element.attributeValue("consumer");
    configuration = new ConnectorConfiguration_(name, producerID, consumerID);
    return configuration;
}

From source file:au.gov.ansto.bragg.process.parse.Parse.java

License:Open Source License

protected static AgentConfiguration getAgentConfiguration(final Element element) {
    String name, principal, uiLabel;
    //      int id = 0;
    String pName = null;//from   ww w.  jav a  2  s .c  o  m
    //      id = Integer.parseInt(element.attributeValue("id"));
    pName = element.attributeValue("pname");
    name = element.attributeValue("name");
    principal = element.attributeValue("principal");
    uiLabel = element.attributeValue("label");
    return new AgentConfiguration_(name, principal, pName, uiLabel);
}

From source file:batch.core.om.Instance.java

License:Open Source License

/** Creates a test instance from a spec meta file. */
public Instance(URL baseUrl, Element instance) throws IOException {
    this(new URL(baseUrl, instance.attributeValue("href")));

    Iterator itr = instance.elementIterator("property");
    while (itr.hasNext()) {
        Element p = (Element) itr.next();
        properties.put(p.attributeValue("name"), p.elementText("value"));
    }/*  w  ww  .  j  a  v a 2s  .co  m*/
}