use of org.apache.commons.jxpath.Variables in project collect by openforis.
the class AbstractSchemaExpression method evaluate.
public Object evaluate(NodeDefinition context, NodeDefinition thisNode) {
if (!(Schema.class.isAssignableFrom(context.getClass()) || NodeDefinition.class.isAssignableFrom(context.getClass()))) {
throw new IllegalArgumentException("Unable to evaluate expression with context class " + context.getClass().getName());
}
JXPathContext jxPathContext = JXPathContext.newContext(CONTEXT, context);
Variables variables = jxPathContext.getVariables();
variables.declareVariable(AbstractExpression.CONTEXT_NODE_VARIABLE_NAME, context);
variables.declareVariable(AbstractExpression.THIS_VARIABLE_NAME, thisNode);
String expr = Path.getNormalizedPath(expression);
Object result = jxPathContext.getValue(expr);
return result;
}
use of org.apache.commons.jxpath.Variables in project collect by openforis.
the class AbstractExpression method createJXPathContext.
/**
* Creates a new JXPath context in order to evaluate the expression
*/
private JXPathContext createJXPathContext(Node<?> contextNode, Node<?> thisNode) {
ModelJXPathContext jxPathContext = ModelJXPathContext.newContext(this.jxPathContext, contextNode);
Variables variables = jxPathContext.getVariables();
variables.declareVariable(CONTEXT_NODE_VARIABLE_NAME, contextNode);
if (thisNode != null) {
variables.declareVariable(THIS_VARIABLE_NAME, thisNode);
}
return jxPathContext;
}
Aggregations