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:
- Example 1 $E{ ${j} > ${currentValue_${k}} }
The value returned here would be of type 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.
- Example 2 $C{$E{ 1 + ${sizeOfVector} }}
The attribute with this value remains constant after the first evaluation.
- Example 3 $L{$E{ 1 + ${sizeOfVector} }}
Evaluates to '$E{ 1 + ${sizeOfVector} }'.
- Example 4 ${container$I{${i}}$I{${j}}}
${container} must represent some indexable object with two levels of indices; depending on what these objects actually dereference to, the two indices ${i} and ${j} could be numerical (implying an array-like structure) or keys (most commonly strings) to a map-like structure. Note that mixing of the two is possible; i.e., one could have an array of maps, a map with lists, etc.
Notice that if the string is a single reference or expression (i.e., '${ ........... }' or '$E{ ........... }'), then the value returned may be an object; otherwise, the value returned by any embedded reference or expression (e.g., '... ${ ... } ...') will be converted to a string, with all such substrings finally concatenated. Hence, composite tags at the top level (e.g., '${ ... }${ ... }$E{ ... }', etc.) will always return a string.
$E{...} denotes an infix-expression evaluating to either a java.lang.Long
, a java.lang.Double
or a java.lang.Boolean
, and having the following constraints:
- 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 simply ingored).
XML Escaped Characters
When coding expressions, the greater-than ('>') and less-than ('<') characters should be escaped to >
and <
.