Example usage for org.dom4j Node valueOf

List of usage examples for org.dom4j Node valueOf

Introduction

In this page you can find the example usage for org.dom4j Node valueOf.

Prototype

String valueOf(String xpathExpression);

Source Link

Document

valueOf evaluates an XPath expression and returns the textual representation of the results the XPath string-value of this node.

Usage

From source file:org.jdbcluster.clustertype.ClusterTypeConfigImpl.java

License:Apache License

/**
 * returns the classname of the given ClusterType
 * @param CTName the ClusterType's name as a String
 * @return String/* w w  w .  j a  va 2s. c o  m*/
 */
public String getClassName(String CTName) {

    //xPath expression to get the classname
    String xPath = "//jdbcluster/clustertype/cluster[@id='" + CTName + "']";

    Node node = document.selectSingleNode(xPath);

    if (node == null) {
        return null;
    } else {
        //returns the classname as a String
        return node.valueOf("@class");
    }
}

From source file:org.jdbcluster.clustertype.ClusterTypeConfigImpl.java

License:Apache License

/**
 * returns a list of all cluster ids/*from  ww w . j  a  v  a2s .c  o m*/
 * @return List<String>
 */
@SuppressWarnings("unchecked")
public List<String> getClusterIDs() {
    ArrayList<String> clusterIDs = new ArrayList<String>();
    //xPath expression to get the classname
    String xPath = "//jdbcluster/clustertype/cluster";

    List<Node> nodes = document.selectNodes(xPath);
    if (nodes != null) {
        for (Node n : nodes) {
            clusterIDs.add(n.valueOf("@id"));
        }
    }
    return clusterIDs;
}

From source file:org.jdbcluster.clustertype.ClusterTypeConfigImpl.java

License:Apache License

/**
 * class name of cluster interceptor//from www. j  av a 2 s.c om
 * @return String
 */
public String getClusterInterceptorClassName() {
    String xPath = "//jdbcluster/clustertype";

    Node node = document.selectSingleNode(xPath);

    if (node == null) {
        return null;
    } else {
        //returns the classname as a String
        return node.valueOf("@clusterInterceptor");
    }
}

From source file:org.jdbcluster.clustertype.ClusterTypeConfigImpl.java

License:Apache License

/**
 * returns the name of the specified clustertype
 * from a given class name/* w w w .  j a  v a2  s  . c  om*/
 * @param className given cluster class name
 * @return cluster type name
 */
public String getClusterTypeFromClass(String className) {
    String xPath = "//jdbcluster/clustertype/cluster[@class='" + className + "']";
    Node node = document.selectSingleNode(xPath);

    if (node == null) {
        return null;
    } else {
        return node.valueOf("@id");
    }
}

From source file:org.jdbcluster.dao.DaoConfigImpl.java

License:Apache License

public String getDaoClass(String daoId) {
    String xPath = "//jdbcluster/daotype/dao[@id='" + daoId + "']";
    Node node = document.selectSingleNode(xPath);

    if (node == null) {
        return null;
    } else {//from  w  w w  . j  a v  a2 s.com
        return node.valueOf("@class");
    }
}

From source file:org.jdbcluster.dao.DaoConfigImpl.java

License:Apache License

public String getDaoId(String daoClass) {
    String xPath = "//jdbcluster/daotype/dao[@class='" + daoClass + "']";
    Node node = document.selectSingleNode(xPath);

    if (node == null) {
        return null;
    } else {//from  www .ja va  2  s  . c om
        return node.valueOf("@id");
    }
}

From source file:org.jdbcluster.dao.DaoConfigImpl.java

License:Apache License

@SuppressWarnings("unchecked")
public String[] getPropertyName(String daoId) {
    String xPath = "//jdbcluster/daotype/dao[@id='" + daoId + "']/property";
    List<Node> nodes = document.selectNodes(xPath);

    if (nodes == null) {
        return null;
    }//from   www  .java2  s  .co m

    String[] res = new String[nodes.size()];
    int i = 0;
    for (Node n : nodes) {
        res[i++] = n.valueOf("@name");
    }
    return res;
}

From source file:org.jdbcluster.dao.DaoConfigImpl.java

License:Apache License

public String getPropertyClass(String daoId, String Property) {
    String xPath = "//jdbcluster/daotype/dao[@id='" + daoId + "']/property[@name='" + Property + "']";
    Node node = document.selectSingleNode(xPath);

    if (node == null) {
        return null;
    } else {//from   ww  w. j  a v  a  2s .  c om
        return node.valueOf("@class");
    }
}

From source file:org.jdbcluster.domain.DomainConfigImpl.java

License:Apache License

/**
 * starts parsing process of entries in 
 * configuration xml file/*from w ww .  ja  v a  2 s. c  o m*/
 * @param configuration
 */
@SuppressWarnings("unchecked")
public void setConfiguration(String configuration) {
    this.configuration = configuration;
    dependancies = new HashMap<String, EntrySet>();
    try {
        document = read(configuration);
    } catch (DocumentException e) {
        e.printStackTrace();
        throw new ConfigurationException("Error in DomainConfig File", e);
    }

    String xPathDomains = "//jdbcluster/domaindependancy/domain";
    List<Node> domainNodes = document.selectNodes(xPathDomains);
    if (domainNodes == null)
        return;

    // iterate over all configured "domain" elements
    for (Node domainNode : domainNodes) {
        String domainId = domainNode.valueOf("@domainid");
        List<Node> domEntryNodes = domainNode.selectNodes("entry");
        EntrySet es = new EntrySet(domainId, domEntryNodes);
        dependancies.put(domainId, es);
    }
}

From source file:org.jdbcluster.domain.DomainConfigImpl.java

License:Apache License

public String getDomainListClass(String domainId) {
    String xPathDomain = "//jdbcluster/domaindependancy/domain[@domainid='" + domainId + "']";
    Node node = document.selectSingleNode(xPathDomain);

    if (node == null) {
        return null;
    }//from   w ww .  j a  v a2  s  .  c o m
    return node.valueOf("@domainlistclass");
}