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.domain.EntrySet.java

License:Apache License

/**
 * filles structure/*from w  w w .ja  va 2  s .  c  om*/
 * @param domEntryNodes
 */
@SuppressWarnings("unchecked")
void fill(List<Node> domEntryNodes, HashMap<String, HashMap<String, ValidEntryList>> topList) {
    for (Node n : domEntryNodes) {
        String domEntryValue = n.valueOf("@value");
        String domEntrySlaveDomain = n.valueOf("@slavedomainid");

        HashMap<String, ValidEntryList> slaveDomainMap = topList.get(domEntryValue);
        if (slaveDomainMap == null) {
            slaveDomainMap = new HashMap<String, ValidEntryList>();
            topList.put(domEntryValue, slaveDomainMap);
        }
        ValidEntryList validValueList = slaveDomainMap.get(domEntrySlaveDomain);
        if (validValueList == null) {
            List<Node> validEntries = n.selectNodes("valid");
            List<Node> invalidEntries = n.selectNodes("invalid");
            List<Node> addMasterEntries = n.selectNodes("additionalmaster");
            validValueList = new ValidEntryList(validEntries, invalidEntries, addMasterEntries);
            slaveDomainMap.put(domEntrySlaveDomain, validValueList);
        }
    }
}

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

License:Apache License

/**
 * parses additional Master Dependancies
 * @param addMasterEntries 1st level of tags
 *//*w w  w . j a  v a2s  . c om*/
@SuppressWarnings("unchecked")
private void fillAddMasterEntries(List<Node> addMasterEntries) {
    /**
     * maps MasterDomainID -> AddMasterDomEntryValue -> ValidEntryList
     */
    addMasterMap = new HashMap<String, HashMap<String, ValidEntryList>>();

    for (Node n : addMasterEntries) {
        String domEntryValue = n.valueOf("@value");
        String domEntryMasterDomain = n.valueOf("@masterdomainid");

        HashMap<String, ValidEntryList> masterDomainMap = addMasterMap.get(domEntryMasterDomain);
        if (masterDomainMap == null) {
            masterDomainMap = new HashMap<String, ValidEntryList>();
            addMasterMap.put(domEntryMasterDomain, masterDomainMap);
        }

        ValidEntryList validValueList = masterDomainMap.get(domEntryValue);
        if (validValueList == null) {
            List<Node> validEntries = n.selectNodes("valid");
            List<Node> invalidEntries = n.selectNodes("invalid");
            List<Node> nextAddMasterEntries = n.selectNodes("additionalmaster");
            validValueList = new ValidEntryList(validEntries, invalidEntries, nextAddMasterEntries);
            masterDomainMap.put(domEntryValue, validValueList);
        }
    }
}

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

License:Apache License

/**
 * Creates Valid objects filles and stores it
 * @param n validation Node/* w  ww  .  j  a va2  s .c o  m*/
 * @param valid Node is a valid or invalid Node
 */
private void fill(Node n, boolean valid) {
    Valid v = new Valid();
    v.valid = valid;

    String allTmp = n.valueOf("@all");
    if (allTmp.length() > 0)
        v.all = allTmp.equalsIgnoreCase("true");

    String nullTmp = n.valueOf("@null");
    if (nullTmp.length() > 0)
        v.nullValue = nullTmp.equalsIgnoreCase("true");

    v.value = n.valueOf("@value");
    if (v.value.length() == 0) {
        v.value = null;
        this.add(v);
    } else {
        mapValuesToValid.put(v.value, v);
    }

    /**
     * given attribute validation
     */
    if (v.value != null && v.value.length() > 0) {
        if (v.all != null || v.nullValue != null)
            throw new ConfigurationException(
                    "given value attribute (<valid value=\"...\">) requires unset null and all attribute");
    } else {
        if (v.all == null)
            if (v.nullValue == null)
                throw new ConfigurationException(
                        "missing all attribute (<valid all=\"...\">) requires existing null attribute");
    }

}

From source file:org.jdbcluster.filter.ClusterSelectImpl.java

License:Apache License

/**
* creates a select string on "selects.xml"
* @param clusterType identifies the ClusterType
* @param SelectID selects the SelectID/*  w w w. j  ava2  s  .c om*/
* @return String
*/
public String getWhere(ClusterType clusterType, String SelectID) {
    String clusterId = clusterType.getName();
    String xPath = "//jdbcluster/clustertype/cluster[@id='" + clusterId + "']" + "/select[@id='" + SelectID
            + "']";

    Node node = document.selectSingleNode(xPath);

    if (node == null)
        throw new CCFilterException("cannot find filter configuration for ClusterID [" + clusterId
                + "] and select Id [" + SelectID + "]");

    return getHqlWithSnippets(node.valueOf("@hql"));
}

From source file:org.jdbcluster.filter.ClusterSelectImpl.java

License:Apache License

/**
 * inserts HQLSnippets to HQL query/*from w w  w .  j a  v a 2 s.c om*/
 * @param hql hql statement to replace
 * @return resulting HQL query
 */
private String getHqlWithSnippets(String hql) {

    Pattern environment_pattern = Pattern.compile("\\|[^\\|]*\\|", Pattern.UNICODE_CASE);

    Matcher environment_matcher = environment_pattern.matcher(hql);

    StringBuffer sb = new StringBuffer();

    while (environment_matcher.find()) {
        String temp = environment_matcher.group();
        String sId = temp.substring(1, temp.length() - 1);
        final String xPath = "//jdbcluster/hqlsnippets/snippet[@id='" + sId + "']";

        Node node = document.selectSingleNode(xPath);
        if (node == null)
            throw new CCFilterException("cannot find filter configuration for HqlSnippet [" + sId + "]");

        environment_matcher.appendReplacement(sb, node.valueOf("@hql"));
    }

    StringBuffer buffer = environment_matcher.appendTail(sb);
    return buffer.toString();
}

From source file:org.jdbcluster.filter.ClusterSelectImpl.java

License:Apache License

/**
 * returns the alias setting/*from w  ww.j a  v  a2  s. c  o m*/
 * @param clusterType identifies the ClusterType
 * @param SelectID selects the SelectID
 * @return String
 */
public String getAlias(ClusterType clusterType, String SelectID) {
    String clusterId = clusterType.getName();
    String xPath = "//jdbcluster/clustertype/cluster[@id='" + clusterId + "']" + "/select[@id='" + SelectID
            + "']";

    Node node = document.selectSingleNode(xPath);

    if (node == null)
        throw new CCFilterException("cannot find filter configuration for ClusterID [" + clusterId
                + "] and select Id [" + SelectID + "]");

    return node.valueOf("@alias");
}

From source file:org.jdbcluster.filter.ClusterSelectImpl.java

License:Apache License

/**
 * returns the alias setting//from  w w  w .  ja v a 2s . c  o  m
 * @param clusterType identifies the ClusterType
 * @param SelectID selects the SelectID
 * @return String
 */
public String getExt(ClusterType clusterType, String SelectID) {
    String clusterId = clusterType.getName();
    String xPath = "//jdbcluster/clustertype/cluster[@id='" + clusterId + "']" + "/select[@id='" + SelectID
            + "']";

    Node node = document.selectSingleNode(xPath);

    if (node == null)
        throw new CCFilterException("cannot find filter configuration for ClusterID [" + clusterId
                + "] and select Id [" + SelectID + "]");

    return node.valueOf("@ext");
}

From source file:org.jdbcluster.filter.ClusterSelectImpl.java

License:Apache License

/**
 * order By statement part/* w ww  .j av  a2s. c o m*/
 * @param clusterType identifies the ClusterType
 * @param selId selects the SelectID
 * @return String
 */
public String getOrderBy(ClusterType clusterType, String SelectID) {
    String clusterId = clusterType.getName();
    String xPath = "//jdbcluster/clustertype/cluster[@id='" + clusterId + "']" + "/select[@id='" + SelectID
            + "']";

    Node node = document.selectSingleNode(xPath);

    if (node == null)
        throw new CCFilterException("cannot find filter configuration for ClusterID [" + clusterId
                + "] and select Id [" + SelectID + "]");

    return node.valueOf("@orderby");
}

From source file:org.jdbcluster.filter.ClusterSelectImpl.java

License:Apache License

/**
 * annotation part//from  ww w  .  j a  v a 2 s .c  o  m
 * @param clusterType identifies the ClusterType
 * @param selId selects the SelectID
 * @return String
 */
public String getAnnotation(ClusterType clusterType, String SelectID) {
    String clusterId = clusterType.getName();
    String xPath = "//jdbcluster/clustertype/cluster[@id='" + clusterId + "']" + "/select[@id='" + SelectID
            + "']";

    Node node = document.selectSingleNode(xPath);

    if (node == null)
        throw new CCFilterException("cannot find filter configuration for ClusterID [" + clusterId
                + "] and select Id [" + SelectID + "]");

    return node.valueOf("@annotation");
}

From source file:org.jdbcluster.filter.ClusterSelectImpl.java

License:Apache License

/**
 * gets the classname from "selects.xml"
 * @param clusterType identifies the ClusterType
 * @param SelectID selects the SelectID//from  www. j a  va 2 s . com
 * @return String
 */
public String getClassName(ClusterType clusterType, String SelectID) {
    String clusterId = clusterType.getName();
    String xPath = "//jdbcluster/clustertype/cluster[@id='" + clusterId + "']" + "/select[@id='" + SelectID
            + "']" + "/FilterClass";

    Node node = document.selectSingleNode(xPath);

    if (node == null)
        throw new CCFilterException("cannot find filter configuration for ClusterID [" + clusterId
                + "] and select Id [" + SelectID + "]");

    return node.valueOf("@class");
}