Search in sources :

Example 6 with Expression

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

the class ReferencedPathEvaluator method determineReferencedPaths.

private Set<String> determineReferencedPaths(Operation operation) {
    Set<String> paths = new HashSet<String>();
    if (operation instanceof ModelExtensionFunction) {
        ModelExtensionFunction modelExtensionFunction = (ModelExtensionFunction) operation;
        Set<String> pathsReferencedByFunction = determineReferencedPaths(modelExtensionFunction);
        paths.addAll(pathsReferencedByFunction);
    }
    Expression[] arguments = operation.getArguments();
    boolean hasArguments = arguments != null && arguments.length > 0;
    if (hasArguments) {
        for (Expression arg : arguments) {
            paths.addAll(determineReferencedPaths(arg));
        }
    }
    return paths;
}
Also used : Expression(org.apache.commons.jxpath.ri.compiler.Expression) HashSet(java.util.HashSet)

Example 7 with Expression

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

the class ModelJXPathCompiledExpression method validateOperations.

private ExpressionValidationResult validateOperations(OperationVaildator operationValidator) {
    Deque<Expression> stack = new LinkedList<Expression>();
    stack.push(getExpression());
    while (!stack.isEmpty()) {
        Expression expression = stack.pop();
        if (expression instanceof Operation) {
            Operation op = (Operation) expression;
            ExpressionValidationResult result = operationValidator.validate(op);
            if (result.isError()) {
                return result;
            } else {
                Expression[] args = op.getArguments();
                if (args != null) {
                    stack.addAll(Arrays.asList(args));
                }
            }
        }
    }
    return new ExpressionValidationResult();
}
Also used : JXPathCompiledExpression(org.apache.commons.jxpath.ri.JXPathCompiledExpression) Expression(org.apache.commons.jxpath.ri.compiler.Expression) Operation(org.apache.commons.jxpath.ri.compiler.Operation) ExpressionValidationResult(org.openforis.idm.metamodel.expression.ExpressionValidator.ExpressionValidationResult) LinkedList(java.util.LinkedList)

Aggregations

Expression (org.apache.commons.jxpath.ri.compiler.Expression)7 HashSet (java.util.HashSet)3 LinkedList (java.util.LinkedList)2 JXPathCompiledExpression (org.apache.commons.jxpath.ri.JXPathCompiledExpression)2 Operation (org.apache.commons.jxpath.ri.compiler.Operation)2 SoftReference (java.lang.ref.SoftReference)1 Iterator (java.util.Iterator)1 Entry (java.util.Map.Entry)1 NodeSet (org.apache.commons.jxpath.NodeSet)1 NodeSetContext (org.apache.commons.jxpath.ri.axes.NodeSetContext)1 CoreFunction (org.apache.commons.jxpath.ri.compiler.CoreFunction)1 Step (org.apache.commons.jxpath.ri.compiler.Step)1 ExpressionValidationResult (org.openforis.idm.metamodel.expression.ExpressionValidator.ExpressionValidationResult)1