public abstract class GroovySCXMLScript extends groovy.lang.Script
Script
base class for SCXML, providing the standard 'builtin' functions In(String)
,
Data(String)
and Location(String)
, as well as JEXL like convenience functions
empty(Object)
and var(String)
.Modifier | Constructor and Description |
---|---|
protected |
GroovySCXMLScript() |
Modifier and Type | Method and Description |
---|---|
Object |
Data(String expression)
Implements the Data() predicate for SCXML documents.
|
boolean |
empty(Object obj)
The empty function mimics the behavior of the JEXL empty function, in that it returns true if the parameter is:
null, or
an empty String, or
an zero length Array, or
an empty Collection, or
an empty Map
Note: one difference with the JEXL language is that Groovy doesn't allow checking for undefined variables.
|
boolean |
In(String state)
Implements the In() predicate for SCXML documents ( see Builtin#isMember )
|
Object |
Location(String location)
Implements the Location() predicate for SCXML documents.
|
void |
setBinding(groovy.lang.Binding binding) |
boolean |
var(String property)
The var function can be used to check if a variable is defined,
In the Groovy language (implementation) you cannot check for an undefined variable directly:
Groovy will raise a MissingPropertyException before you get the chance.
|
protected GroovySCXMLScript()
public void setBinding(groovy.lang.Binding binding)
setBinding
in class groovy.lang.Script
public boolean In(String state)
state
- The State ID to compare withpublic Object Data(String expression) throws SCXMLExpressionException
expression
- the XPath expressionSCXMLExpressionException
public Object Location(String location) throws SCXMLExpressionException
location
- the XPath expressionSCXMLExpressionException
public boolean var(String property)
In the Groovy language (implementation) you cannot check for an undefined variable directly: Groovy will raise a MissingPropertyException before you get the chance.
The var function works around this by indirectly looking up the variable, which you therefore have to specify as a String.
So, use var('name')
, not var(name)
Note: this function doesn't support object navigation, like var('name.property')
.
Instead, once you established a variable 'name' exists, you thereafter can use the standard Groovy
Safe Navigation operator (?.), like so: name?.property
.
See for more information: Groovy SafeNavigationOperator
public boolean empty(Object obj)
Note: one difference with the JEXL language is that Groovy doesn't allow checking for undefined variables.
Before being able to check, Groovy will already have raised an MissingPropertyException if the variable cannot be found.
To work around this, the custom var(String)
function is available.
Copyright © 2005–2015 The Apache Software Foundation. All rights reserved.