Package org.apache.ofbiz.base.util
Class GroovyUtil
java.lang.Object
org.apache.ofbiz.base.util.GroovyUtil
Groovy Utilities.
-
Method Summary
Modifier and TypeMethodDescriptionstatic Object
Evaluate a Groovy condition or expressionstatic Binding
getBinding
(Map<String, Object> context) static Class<?>
getScriptClassFromLocation
(String location) static Class<?>
parseClass
(String text) Parses a Groovy class from a text.static Object
Runs a Groovy script with a context argument.
-
Method Details
-
eval
public static Object eval(String expression, Map<String, Object> context) throws CompilationFailedExceptionEvaluate a Groovy condition or expression- Parameters:
expression
- The expression to evaluatecontext
- The context to use in evaluation (re-written)- Returns:
- Object The result of the evaluation
- Throws:
CompilationFailedException
- See Also:
-
getBinding
-
getScriptClassFromLocation
- Throws:
GeneralException
-
parseClass
Parses a Groovy class from a text.- Parameters:
text
- as flexible string to parse- Returns:
- the corresponding class object
- Throws:
IOException
- when parsing fails
-
runScriptAtLocation
public static Object runScriptAtLocation(String location, String methodName, Map<String, Object> context) throws GeneralExceptionRuns a Groovy script with a context argument.A Groovy script can be either a stand-alone script or a method embedded in a script.
- Parameters:
location
- the location of the script filemethodName
- the name of the method inside the script to be run, if it isnull
consider the script as stand-alonecontext
- the context of execution which is in the case of a method inside a script passed as an argument- Returns:
- the invocation result
- Throws:
GeneralException
- when the script is not properly located
-