use of org.apache.commons.jxpath.ri.compiler.Operation 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;
}
use of org.apache.commons.jxpath.ri.compiler.Operation 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();
}
Aggregations