use of io.atlasmap.v2.Expression in project dhis2-core by dhis2.
the class ExpressionUtils method evaluate.
/**
* @param expression the expression.
* @param vars the variables, can be null.
* @param strict indicates whether to use strict or lenient engine mode.
* @return the result of the evaluation.
*/
private static Object evaluate(String expression, Map<String, Object> vars, boolean strict) {
expression = expression.replaceAll(IGNORED_KEYWORDS_REGEX, StringUtils.EMPTY);
JexlEngine engine = strict ? JEXL_STRICT : JEXL;
Expression exp = engine.createExpression(expression);
JexlContext context = vars != null ? new MapContext(vars) : new MapContext();
return exp.evaluate(context);
}
use of io.atlasmap.v2.Expression in project vorto by eclipse.
the class DataMapperJxpath method matchesPropertyCondition.
private boolean matchesPropertyCondition(Stereotype stereotype, JXPathContext context) {
if (stereotype.hasAttribute(ATTRIBUTE_CONDITION)) {
Expression e = jexlEngine.createExpression(normalizeCondition(stereotype.getAttributes().get(ATTRIBUTE_CONDITION)));
JexlContext jc = new ObjectContext<Object>(jexlEngine, context.getContextBean());
jc.set("this", context.getContextBean());
return (boolean) e.evaluate(jc);
} else {
return true;
}
}
Aggregations