Package com.axelor.data
Class DataScriptHelper
java.lang.Object
com.axelor.data.DataScriptHelper
This
The
DataScriptHelper
class can be used to effectively use the GroovyShell
to
evaluate dynamic groovy expressions. The
DataScriptHelper
maintains an internal LRU cache to reuse the parsed script. If the
specified expiry time is elapsed without any access to the cached script, the cache is evicted to
regain the memory.-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
DataScriptHelper
public DataScriptHelper(int cacheSize, int expireTime, boolean indy) - Parameters:
cacheSize
- Size of the cache.expireTime
- The expire time in minutes after which the script is evicted from the cache if not accessed.indy
- Whether to use the invoke dynamic feature.
-
-
Method Details
-
eval
Evaluate the given expression.
An instance ofBinding
is created to deal with missing variables. In that case,null
is returned and avoidsMissingPropertyException
.- Parameters:
expression
- the groovy expression to evaluatevariables
- the binding variables- Returns:
- the result of the expression
-
eval
Evaluate the given expression.- Parameters:
expression
- the groovy expression to evaluatebinding
- the binding variables- Returns:
- the result of the expression
-