This is essentially the same as the OGRE expression language, with the following changes:
- The reference tag
$R
has been eliminated, with variables and properties generalized to$
. - The index tag
$I
has been generalized to include keys to a Map.
TAG | TYPE |
---|---|
${...} | Reference |
$C{...} | Constant |
$E{...} | Logico-Arithmetic Expression |
$G{...} | Global Reference |
$I{...} | Index to Array-like Reference, or Key to Map |
$L{...} | Literal |
Except for restrictions on the placement of index tags (they must be inside a reference and cannot be nested inside other index tags), all of these are nestable within one another and to an arbitrary depth. Some simpler examples:
...
The value returned here would be of type java.lang.Boolean
; the value of k would be appended to 'currentValue_' and this string used as the name of another reference which should correspond to a stored numerical value; the value of j would then be compared to it.
...
- all operators and operands must be white-space delimited (but unary -/+ should remain attached to its argument)
- any of the Java operators except: ternary condition ' ? : ', cast, instanceof, assignment (++ and – - here are merely shorthand for + 1 and - 1, with no side-effecting implied)
- any of the functions available from
java.lang.Math
; parameters must be comma-delimited inside the parentheses - any numeric operand
pi
,e
true
,false
The resulting string is not type-checked, but loose parenthesis matching is enforced (e.g., '( 1 * ( 2 - 3 )' or '( 1 * ( 2 - 3 ) ) )' will be rejected, but '( ) ( 1 * ( 2 - 3 ) )' will be accepted, with the empty parenthesis parentheses simply ingored).
XML Escaped Characters
When coding expressions, the greater-than ('>') and less-than ('<') characters should be escaped to >
and <
. >
and <
.
...
An example, with output, of expressions, constants and literals, using a for container task:
Code Block | ||||
---|---|---|---|---|
| ||||
<ogrescript strict="true">
<for var="i" from="0" to="10">
<echo stdout="true" message="******************** ${i} ********************"/>
<echo stdout="true" message="the expression value is $E{ 10 * ( ${i} + 1 ) }"/>
<echo stdout="true" message="the constant value is $C{$E{ 10 * ( ${i} + 1 ) }}"/>
<echo stdout="true" message="the literal value is '$L{$E{ 10 * ( ${i} + 1 ) }}'"/>
</for>
<echo stdout="true" message="********************************************"/>
</ogrescript>
|
OUTPUT:
******************* 0 *******************
the expression value is 10
the constant value is 10
the literal value is '$E{ 10 * ( ${i} + 1 ) }'
******************* 1 *******************
the expression value is 20
the constant value is 10
the literal value is '$E{ 10 * ( ${i} + 1 ) }'
******************* 2 *******************
the expression value is 30
the constant value is 10
the literal value is '$E{ 10 * ( ${i} + 1 ) }'
******************* 3 *******************
the expression value is 40
the constant value is 10
the literal value is '$E{ 10 * ( ${i} + 1 ) }'
******************* 4 *******************
the expression value is 50
the constant value is 10
the literal value is '$E{ 10 * ( ${i} + 1 ) }'
******************* 5 *******************
the expression value is 60
the constant value is 10
the literal value is '$E{ 10 * ( ${i} + 1 ) }'
******************* 6 *******************
the expression value is 70
the constant value is 10
the literal value is '$E{ 10 * ( ${i} + 1 ) }'
******************* 7 *******************
the expression value is 80
the constant value is 10
the literal value is '$E{ 10 * ( ${i} + 1 ) }'
******************* 8 *******************
the expression value is 90
the constant value is 10
the literal value is '$E{ 10 * ( ${i} + 1 ) }'
******************* 9 *******************
the expression value is 100
the constant value is 10
the literal value is '$E{ 10 * ( ${i} + 1 ) }'
******************* 10 *******************
the expression value is 110
the constant value is 10
the literal value is '$E{ 10 * ( ${i} + 1 ) }'
********************************************