Package org.apache.ofbiz.base.util
Class GroovyUtil
- java.lang.Object
-
- org.apache.ofbiz.base.util.GroovyUtil
-
public class GroovyUtil extends java.lang.Object
Groovy Utilities.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
module
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.Object
eval(java.lang.String expression, java.util.Map<java.lang.String,java.lang.Object> context)
Evaluate a Groovy condition or expressionstatic Binding
getBinding(java.util.Map<java.lang.String,java.lang.Object> context)
static Binding
getBinding(java.util.Map<java.lang.String,java.lang.Object> context, java.lang.String expression)
Returns aBinding
instance initialized with the variables contained incontext
.static java.lang.Class<?>
getScriptClassFromLocation(java.lang.String location)
static java.lang.Class<?>
loadClass(java.lang.String path)
static java.lang.Class<?>
parseClass(java.io.InputStream in, java.lang.String location)
static java.lang.Class<?>
parseClass(java.io.InputStream in, java.lang.String location, GroovyClassLoader groovyClassLoader)
static java.lang.Class<?>
parseClass(java.lang.String text)
static java.lang.Object
runScriptAtLocation(java.lang.String location, java.lang.String methodName, java.util.Map<java.lang.String,java.lang.Object> context)
-
-
-
Method Detail
-
eval
public static java.lang.Object eval(java.lang.String expression, java.util.Map<java.lang.String,java.lang.Object> context) throws CompilationFailedException
Evaluate 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:
- StringUtil.convertOperatorSubstitutions(java.lang.String)
-
getBinding
public static Binding getBinding(java.util.Map<java.lang.String,java.lang.Object> context, java.lang.String expression)
Returns aBinding
instance initialized with the variables contained incontext
. Ifcontext
isnull
, an emptyBinding
is returned.The expression is parsed to initiate non existing variable in
Binding
to null for GroovyShell evaluation.The
context Map
is added to theBinding
as a variable called "context" so that variables can be passed back to the caller. Any variables that are created in the script are lost when the script ends unless they are copied to the "context"Map
.- Parameters:
context
- AMap
containing initial variables- Returns:
- A
Binding
instance
-
getBinding
public static Binding getBinding(java.util.Map<java.lang.String,java.lang.Object> context)
-
getScriptClassFromLocation
public static java.lang.Class<?> getScriptClassFromLocation(java.lang.String location) throws GeneralException
- Throws:
GeneralException
-
loadClass
public static java.lang.Class<?> loadClass(java.lang.String path) throws java.lang.ClassNotFoundException, java.io.IOException
- Throws:
java.lang.ClassNotFoundException
java.io.IOException
-
parseClass
public static java.lang.Class<?> parseClass(java.io.InputStream in, java.lang.String location) throws java.io.IOException
- Throws:
java.io.IOException
-
parseClass
public static java.lang.Class<?> parseClass(java.io.InputStream in, java.lang.String location, GroovyClassLoader groovyClassLoader) throws java.io.IOException
- Throws:
java.io.IOException
-
parseClass
public static java.lang.Class<?> parseClass(java.lang.String text) throws java.io.IOException
- Throws:
java.io.IOException
-
runScriptAtLocation
public static java.lang.Object runScriptAtLocation(java.lang.String location, java.lang.String methodName, java.util.Map<java.lang.String,java.lang.Object> context) throws GeneralException
- Throws:
GeneralException
-
-