Search in sources :

Example 1 with CoreFunction

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

the class ModelJXPathCompiledExpression method getFunctionNames.

public Set<String> getFunctionNames() {
    Set<String> names = new HashSet<String>();
    Deque<Expression> stack = new LinkedList<Expression>();
    stack.push(getExpression());
    while (!stack.isEmpty()) {
        Expression expression = stack.pop();
        if (expression instanceof Operation) {
            if (expression instanceof CoreFunction || expression instanceof ModelExtensionFunction) {
                String name = expression.toString().replaceAll("\\(.*\\)", "");
                names.add(name);
            }
            Expression[] arguments = ((Operation) expression).getArguments();
            if (arguments != null && arguments.length > 0) {
                for (Expression arg : arguments) {
                    stack.push(arg);
                }
            }
        }
    }
    return names;
}
Also used : CoreFunction(org.apache.commons.jxpath.ri.compiler.CoreFunction) JXPathCompiledExpression(org.apache.commons.jxpath.ri.JXPathCompiledExpression) Expression(org.apache.commons.jxpath.ri.compiler.Expression) Operation(org.apache.commons.jxpath.ri.compiler.Operation) LinkedList(java.util.LinkedList) HashSet(java.util.HashSet)

Aggregations

HashSet (java.util.HashSet)1 LinkedList (java.util.LinkedList)1 JXPathCompiledExpression (org.apache.commons.jxpath.ri.JXPathCompiledExpression)1 CoreFunction (org.apache.commons.jxpath.ri.compiler.CoreFunction)1 Expression (org.apache.commons.jxpath.ri.compiler.Expression)1 Operation (org.apache.commons.jxpath.ri.compiler.Operation)1