Package com.axelor.script
Interface ScriptHelper
-
- All Known Implementing Classes:
AbstractScriptHelper,CompositeScriptHelper,ELScriptHelper,GroovyScriptHelper,JavaScriptScriptHelper
public interface ScriptHelperThe DataScriptHelper interface to implement dynamic script evaluation support.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Objectcall(Object obj, String methodCall)Call a method on the given object.Objecteval(String expr)Evaluate the given expression.Objecteval(String expr, Bindings bindings)Evaluate the given expression with the given bindings.BindingsgetBindings()Get current script bindings.voidsetBindings(Bindings bindings)Set script bindings.booleantest(String expr)Evaluate a boolean expression.
-
-
-
Method Detail
-
getBindings
Bindings getBindings()
Get current script bindings.- Returns:
- bindings
-
setBindings
void setBindings(Bindings bindings)
Set script bindings.- Parameters:
bindings- new script bindings.
-
eval
Object eval(String expr)
Evaluate the given expression.- Parameters:
expr- the expression to evaluate- Returns:
- expression result
-
eval
Object eval(String expr, Bindings bindings) throws Exception
Evaluate the given expression with the given bindings.- Parameters:
expr- the expression to evaluatebindings- the context bindings- Returns:
- expression result
- Throws:
Exception
-
test
boolean test(String expr)
Evaluate a boolean expression.- Parameters:
expr- a boolean expression- Returns:
- true or false
-
call
Object call(Object obj, String methodCall)
Call a method on the given object.The methodCall is a string expression containing arguments to be passed. For example:
scriptHelper.call(bean, "test(var1, var2, var3)");
This is a convenient method to call:scriptHelper.call(bean, "test", new Object[] { var1, var2, var3 });- Parameters:
obj- the object on which method should be calledmethodCall- method call expression- Returns:
- return value of the method
-
-