use of org.apache.commons.jexl3.MapContext 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 org.apache.commons.jexl3.MapContext in project cxf by apache.
the class JexlClaimsMapper method mapClaims.
public ProcessedClaimCollection mapClaims(String sourceRealm, ProcessedClaimCollection sourceClaims, String targetRealm, ClaimsParameters parameters) {
JexlContext context = new MapContext();
context.set("sourceClaims", sourceClaims);
context.set("targetClaims", new ProcessedClaimCollection());
context.set("sourceRealm", sourceRealm);
context.set("targetRealm", targetRealm);
context.set("claimsParameters", parameters);
Script s = getScript();
if (s == null) {
LOG.warning("No claim mapping script defined");
// TODO Check if null or an exception would be more
return new ProcessedClaimCollection();
// appropriate
}
return (ProcessedClaimCollection) s.execute(context);
}
Aggregations