Search in sources :

Example 1 with Step

use of org.apache.commons.jxpath.ri.compiler.Step in project collect by openforis.

the class ReferencedPathEvaluator method determineReferencedPaths.

private Set<String> determineReferencedPaths(org.apache.commons.jxpath.ri.compiler.Path modelLocationPath) {
    Set<String> paths = new HashSet<String>();
    if (modelLocationPath.getSteps().length > 0) {
        paths.add(Path.getAbsolutePath(modelLocationPath.toString()));
        StringBuilder predicateBasePathSB = new StringBuilder();
        for (Step step : modelLocationPath.getSteps()) {
            String stepVal = step.toString();
            predicateBasePathSB.append(Path.getAbsolutePath(stepVal)).append(Path.SEPARATOR);
            for (Expression predicate : step.getPredicates()) {
                Set<String> predicatePaths = determineReferencedPaths(predicate);
                for (String predicateReferencePath : predicatePaths) {
                    if (predicateReferencePath.startsWith(Path.THIS_VARIABLE) || predicateReferencePath.startsWith(Path.CONTEXT_VARIABLE)) {
                        paths.add(predicateReferencePath);
                    } else {
                        paths.add(predicateBasePathSB.toString() + predicateReferencePath);
                    }
                }
            }
        }
    }
    return paths;
}
Also used : Expression(org.apache.commons.jxpath.ri.compiler.Expression) Step(org.apache.commons.jxpath.ri.compiler.Step) HashSet(java.util.HashSet)

Aggregations

HashSet (java.util.HashSet)1 Expression (org.apache.commons.jxpath.ri.compiler.Expression)1 Step (org.apache.commons.jxpath.ri.compiler.Step)1