String[] parameterNames = {"e"};
Class[] parameterTypes = {LoggingEvent.class};
Class[] thrownExceptions = new Class[0];
// Create "ExpressionEvaluator" object.
ExpressionEvaluator ee = new ExpressionEvaluator(expression,
optionalExpressionType, parameterNames, parameterTypes,
thrownExceptions, null // optionalClassLoader
);
Object[] parameterValues = new Object[1];
LoggerContext lc = new LoggerContext();
Logger logger = lc.getLogger(JaninoTest.class);
LoggingEvent loggingEvent = new LoggingEvent("toto", logger, Level.INFO, "hi", null);
parameterValues[0] = loggingEvent;
Object res = ee.evaluate(parameterValues);
// Print expression result.
System.out.println("Result = " + DemoBase.toString(res));
System.out.println("Type = " + res.getClass().getName());
loop(ee, parameterValues);
// loggingEvent.getMarker()
expression = "import ch.qos.logback.classic.Level; (e.getMarker() != null) && (e.getMarker().contains(\"yo\"))";
ee = new ExpressionEvaluator(expression,
optionalExpressionType, parameterNames, parameterTypes,
thrownExceptions, null);
res = ee.evaluate(parameterValues);
// Print expression result.
System.out.println("Result = " + DemoBase.toString(res));
System.out.println("Type = " + res.getClass().getName());
loop(ee, parameterValues);