Package com.axelor.data
Class DataScriptHelper
- java.lang.Object
-
- com.axelor.data.DataScriptHelper
-
public final class DataScriptHelper extends Object
ThisDataScriptHelperclass can be used to effectively use theGroovyShellto evaluate dynamic groovy expressions.
TheDataScriptHelpermaintains 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 Objecteval(String expression, groovy.lang.Binding binding)Evaluate the given expression.Objecteval(String expression, Map<String,Object> variables)Evaluate the given expression.
An instance ofBindingis 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 ofBindingis created to deal with missing variables. In that case,nullis returned and avoidsMissingPropertyException.- Parameters:
expression- the groovy expression to evaluatevariables- the binding variables- Returns:
- the result of the expression
-
-