public class GroovyEvaluator extends Object implements Evaluator, Serializable
This implementation itself is thread-safe, so you can keep singleton for efficiency.
Modifier and Type | Class and Description |
---|---|
static class |
GroovyEvaluator.GroovyEvaluatorProvider |
Evaluator.AssignType
Modifier and Type | Field and Description |
---|---|
protected static GroovyExtendableScriptCache.ScriptPreProcessor |
scriptPreProcessor |
static String |
SUPPORTED_DATA_MODEL |
DEFAULT_DATA_MODEL, ECMASCRIPT_DATA_MODEL, NULL_DATA_MODEL, XPATH_DATA_MODEL
Constructor and Description |
---|
GroovyEvaluator() |
GroovyEvaluator(boolean useInitialScriptAsBaseScript) |
Modifier and Type | Method and Description |
---|---|
void |
clearCache() |
Object |
eval(Context ctx,
String expr)
Evaluate an expression.
|
void |
evalAssign(Context ctx,
String location,
Object data,
Evaluator.AssignType type,
String attr)
Assigns data to a location
|
Boolean |
evalCond(Context ctx,
String expr)
Evaluate a condition.
|
Object |
evalLocation(Context ctx,
String expr)
Evaluate a location that returns a data assignable reference or list of references.
|
Object |
evalScript(Context ctx,
String scriptSource)
Evaluate a script.
|
protected GroovyContext |
getEffectiveContext(GroovyContext nodeCtx)
Create a new context which is the summation of contexts from the
current state to document root, child has priority over parent
in scoping rules.
|
protected ClassLoader |
getGroovyClassLoader() |
protected groovy.lang.Script |
getScript(GroovyContext groovyContext,
String scriptBaseClassName,
String scriptSource) |
GroovyExtendableScriptCache.ScriptPreProcessor |
getScriptPreProcessor() |
String |
getSupportedDatamodel()
Get the datamodel type supported by this Evaluator
|
Context |
newContext(Context parent)
Create a new child context.
|
protected GroovyExtendableScriptCache |
newScriptCache()
Overridable factory method to create the GroovyExtendableScriptCache for this GroovyEvaluator.
|
public static final String SUPPORTED_DATA_MODEL
protected static final GroovyExtendableScriptCache.ScriptPreProcessor scriptPreProcessor
public GroovyEvaluator()
public GroovyEvaluator(boolean useInitialScriptAsBaseScript)
protected GroovyExtendableScriptCache newScriptCache()
The default implementation configures the scriptCache to use the GroovyEvaluator scriptPreProcessor
and the GroovySCXMLScript
as script base class.
protected groovy.lang.Script getScript(GroovyContext groovyContext, String scriptBaseClassName, String scriptSource)
public void clearCache()
public GroovyExtendableScriptCache.ScriptPreProcessor getScriptPreProcessor()
public String getSupportedDatamodel()
Evaluator
getSupportedDatamodel
in interface Evaluator
public Object eval(Context ctx, String expr) throws SCXMLExpressionException
eval
in interface Evaluator
ctx
- variable contextexpr
- expressionSCXMLExpressionException
- For a malformed expressionEvaluator.eval(Context, String)
public Boolean evalCond(Context ctx, String expr) throws SCXMLExpressionException
Evaluator
evalCond
in interface Evaluator
ctx
- variable contextexpr
- expressionSCXMLExpressionException
- A malformed expression exceptionEvaluator.evalCond(Context, String)
public Object evalLocation(Context ctx, String expr) throws SCXMLExpressionException
Evaluator
evalLocation
in interface Evaluator
ctx
- variable contextexpr
- expressionSCXMLExpressionException
- A malformed expression exceptionEvaluator.evalLocation(Context, String)
public void evalAssign(Context ctx, String location, Object data, Evaluator.AssignType type, String attr) throws SCXMLExpressionException
Evaluator
evalAssign
in interface Evaluator
ctx
- variable contextlocation
- location expressiondata
- the data to assign.type
- the type of assignment to perform, null assumes Evaluator.AssignType.REPLACE_CHILDREN
attr
- the name of the attribute to add when using type Evaluator.AssignType.ADD_ATTRIBUTE
SCXMLExpressionException
- A malformed expression exceptionEvaluator.evalAssign(Context, String, Object, AssignType, String)
public Object evalScript(Context ctx, String scriptSource) throws SCXMLExpressionException
Evaluator
evalScript
in interface Evaluator
ctx
- variable contextscriptSource
- The scriptSCXMLExpressionException
- A malformed scriptEvaluator.evalScript(Context, String)
protected ClassLoader getGroovyClassLoader()
public Context newContext(Context parent)
newContext
in interface Evaluator
parent
- parent contextEvaluator.newContext(Context)
protected GroovyContext getEffectiveContext(GroovyContext nodeCtx)
nodeCtx
- The GroovyContext for this state.Copyright © 2005–2015 The Apache Software Foundation. All rights reserved.