use of org.apache.commons.jxpath.JXPathContext in project vorto by eclipse.
the class AbstractDataMapper method newContext.
private JXPathContext newContext(Object ctxObject) {
JXPathContext context = JXPathContext.newContext(ctxObject);
TypeUtils.setTypeConverter(new MyTypeConverter());
context.setLenient(false);
return context;
}
use of org.apache.commons.jxpath.JXPathContext in project tesb-rt-se by Talend.
the class JxPathFilter method filter.
/* (non-Javadoc)
* @see org.talend.esb.sam.common.spi.EventFilter#filter(org.talend.esb.sam.common.event.Event)
*/
@Override
public boolean filter(Event event) {
JXPathContext context = JXPathContext.newContext(event);
Pointer pointer = context.getPointer(expression);
return (Boolean) pointer.getValue();
}
use of org.apache.commons.jxpath.JXPathContext 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.JXPathContext in project collect by openforis.
the class AbstractExpression method evaluateSingle.
protected Object evaluateSingle(Node<?> contextNode, Node<?> thisNode) throws InvalidExpressionException {
try {
JXPathContext jxPathContext = createJXPathContext(contextNode, thisNode);
Object object = compiledExpression.getValue(jxPathContext);
return object;
} catch (IllegalArgumentException e) {
throw new InvalidExpressionException(e.getMessage(), this.compiledExpression.toString());
} catch (JXPathInvalidSyntaxException e) {
throw new InvalidExpressionException(e.getMessage(), this.compiledExpression.toString());
} catch (JXPathNotFoundException e) {
return null;
}
}
use of org.apache.commons.jxpath.JXPathContext in project vorto by eclipse.
the class JxPathContextFactory method getSharedContext.
private JXPathContext getSharedContext() {
JXPathContext context = JXPathContext.newContext(null);
context.setLenient(true);
return context;
}
Aggregations