Package com.axelor.data
Class DataScriptHelper
- java.lang.Object
-
- com.axelor.data.DataScriptHelper
-
public final class DataScriptHelper extends Object
ThisDataScriptHelper
class can be used to effectively use theGroovyShell
to evaluate dynamic groovy expressions.
TheDataScriptHelper
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 Constructor Description DataScriptHelper(int cacheSize, int expireTime, boolean indy)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Object
eval(String expression, groovy.lang.Binding binding)
Evaluate the given expression.Object
eval(String expression, Map<String,Object> variables)
Evaluate the given expression.
An instance ofBinding
is created to deal with missing variables.
-
-
-
Constructor Detail
-
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 Detail
-
eval
public Object eval(String expression, Map<String,Object> variables)
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
-
-