How to get all warning message of unknown variables?
I have a expression which I would like to evaluate and know all the missing variables.
Example:
jexl.setStrict(false);
Expression e = (Expression) jexl.createExpression("(pqr||abc)&&xyx&&!(rsw||ruy)&&!sss");
JexlContext context = new MapContext();
context.set("rsw",false);
context.set("xyx",true);
Object obj=e.evaluate(context);
System.out.println(obj);
Output:
Aug 11, 2017 10:58:24 AM org.apache.commons.jexl2.Interpreter unknownVariable
WARNING: com.AdhocPrograms.JexlExample.main@40![1,4]: '(pqr || abc) && xyx && !(rsw || ruy) && !sss;' undefined variable pqr
false
Aug 11, 2017 10:58:24 AM org.apache.commons.jexl2.Interpreter unknownVariable
WARNING: com.AdhocPrograms.JexlExample.main@40![8,11]: '(pqr || abc) && xyx && !(rsw || ruy) && !sss;' undefined variable abc
I would like to capture both of the undefined variables. If I set jexl.setStrict(true) and add try and catch block, I can capture only one variable.
catch(JexlException.Variable xjexl) {
System.out.println("Exception:" +xjexl.getVariable());
xjexl.printStackTrace();
}
I am open to use another technology as well.