public class JSEvaluator extends Object implements Evaluator
Mozilla Rhino 1.6.2 does not support E4X so accessing the SCXML data model is implemented in the same way as the JEXL expression evaluator i.e. using the Data() function, for example, <assign location="Data(hotelbooking,'hotel/rooms')" expr="2" />
| Modifier and Type | Class and Description | 
|---|---|
| static class  | JSEvaluator.JSEvaluatorProvider | 
Evaluator.AssignType| Modifier and Type | Field and Description | 
|---|---|
| static String | SUPPORTED_DATA_MODEL | 
DEFAULT_DATA_MODEL, ECMASCRIPT_DATA_MODEL, NULL_DATA_MODEL, XPATH_DATA_MODEL| Constructor and Description | 
|---|
| JSEvaluator()Initialises the internal Javascript engine factory. | 
| Modifier and Type | Method and Description | 
|---|---|
| Object | eval(Context context,
        String expression)Evaluates the expression using a new Javascript engine obtained from
 factory instantiated in the constructor. | 
| void | evalAssign(Context ctx,
                    String location,
                    Object data,
                    Evaluator.AssignType type,
                    String attr)Assigns data to a location | 
| Boolean | evalCond(Context context,
                String expression)Evaluates a conditional expression using the  eval()method and
 casting the result to a Boolean. | 
| Object | evalLocation(Context context,
                        String expression)Evaluates a location expression using a new Javascript engine obtained from
 factory instantiated in the constructor. | 
| Object | evalScript(Context ctx,
                    String script)Executes the script using a new Javascript engine obtained from
 factory instantiated in the constructor. | 
| protected JSContext | getEffectiveContext(JSContext 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. | 
| String | getSupportedDatamodel()Get the datamodel type supported by this Evaluator | 
| Context | newContext(Context parent)Creates a child context. | 
public static final String SUPPORTED_DATA_MODEL
public JSEvaluator()
public String getSupportedDatamodel()
EvaluatorgetSupportedDatamodel in interface Evaluatorpublic Context newContext(Context parent)
newContext in interface Evaluatorparent - parent contextpublic Object eval(Context context, String expression) throws SCXMLExpressionException
Data() functions are replaced with an equivalent internal
 Javascript function.eval in interface Evaluatorcontext - SCXML context.expression - Expression to evaluate.null.SCXMLExpressionException - Thrown if the expression was invalid.public Boolean evalCond(Context context, String expression) throws SCXMLExpressionException
eval() method and
 casting the result to a Boolean.evalCond in interface Evaluatorcontext - SCXML context.expression - Expression to evaluate.null.SCXMLExpressionException - Thrown if the expression was invalid or did
                                  not return a boolean.public Object evalLocation(Context context, String expression) throws SCXMLExpressionException
Data() functions are replaced with an equivalent internal
 Javascript function.evalLocation in interface Evaluatorcontext - FSM context.expression - Expression to evaluate.SCXMLExpressionException - Thrown if the expression was invalid.public void evalAssign(Context ctx, String location, Object data, Evaluator.AssignType type, String attr) throws SCXMLExpressionException
EvaluatorevalAssign in interface Evaluatorctx - variable contextlocation - location expressiondata - the data to assign.type - the type of assignment to perform, null assumes Evaluator.AssignType.REPLACE_CHILDRENattr - the name of the attribute to add when using type Evaluator.AssignType.ADD_ATTRIBUTESCXMLExpressionException - A malformed expression exceptionEvaluator.evalAssign(Context, String, Object, AssignType, String)public Object evalScript(Context ctx, String script) throws SCXMLExpressionException
Data() functions are replaced with an equivalent internal
 Javascript function.evalScript in interface Evaluatorctx - SCXML context.script - Script to execute.null.SCXMLExpressionException - Thrown if the script was invalid.protected JSContext getEffectiveContext(JSContext nodeCtx)
nodeCtx - The JexlContext for this state.Copyright © 2005–2015 The Apache Software Foundation. All rights reserved.