JEXL Flags

JETT uses an internal "JEXL Engine", supplied by the Apache Commons JEXL library, to evaluate the expressions. The ExcelTransformer passes three flags through to the JexlEngine, "silent", "lenient", and "debug". The "silent" flag tells the JexlEngine not to write errors to standard output. The "lenient" flag tells the JexlEngine to allow such things as converting nulls to zeroes, NullPointerExceptions to null, etc. Otherwise, JEXL might throw an Exception or write a log message to standard output. The "debug" flag, which by default is set in the JexlEngine, controls debug information. Turning off "debug" may improve the performance of the JexlEngine and therefore the performance of JETT.

JETT exposes control of these flags through the following methods in the ExcelTransformer class.

public void setLenient(boolean lenient);
public void setSilent(boolean silent);
public void setDebug(boolean debug);

JEXL Cache

The ExcelTransformer passes the "cache" parameter to its internal JEXL Engine. This parameter controls the size of the JEXL Engine's parse cache. It will cache the parse tree for a certain number of Expressions. It is not a result cache; even on a cache hit, it will still need to evaluate the Expression. However, it won't need to parse the Expression, unless it is aged out or memory concerns remove cache entries.

JETT exposes the cache parameter through the following method in the ExcelTransformer class.

public void setCache(int size);

Registering Functions in Custom Namespaces

It is possible to pass objects that represent custom functionality to the JEXL Engine. The JEXL Engine associates a namespace with the object, and the developer is able to reference the custom functionality within Expressions.

ExcelTransformer transformer = new ExcelTransformer();
transformer.registerFuncs("custom", new AnyObject());
${custom:method('custom method')}

...gets transformed into...

I am a custom method!

... or, for static methods...

ExcelTransformer transformer = new ExcelTransformer();
transformer.registerFuncs("math", Math.class);

Here, the "pi" bean has the value Math.PI.


...gets transformed into...