To define symbols, you must use expressions. The agent
evaluates the expressions to assign values to symbols.
Using data in an expression
An expression can
use the following data:
- The input data symbols for the request type (for more information,
see Table 1).
- Other symbols described in the same request mapper definition.
- Numeric constants
- String constants (delimited with ", for example, "string")
- Boolean constants (true, TRUE, false, FALSE)
- The null constant.
If the value of a symbol is an instantiation of a Java™ class, expressions can contain references
to fields and methods that are defined within the class. To refer
to a field, use symbol.fieldname.
To refer to a method, use symbol.methodname(parameters).
The method call must return a value. For example, you can use the Java String methods with a symbol
that has a String value.
To refer to a static field or method
of a class, you can also use classname.fieldname and classname.methodname(parameters).
If
a symbol refers to an array object, the expression can select an element
(symbol[selector])
and determine the length of the array (symbol.length)
Operators
You can use the following operators
in an expression:
- Boolean operators: AND, &, OR, |, NOT, !
- Comparison: ==, !=, GT, >, LT, <, GE, >=, LE, <=
- Numeric operators: +, -, *, /
- Parentheses to force order of evaluation: (, )
Important: You must escape the symbols <, >,
and & in XML. Alternatively, you can use the GT (greater
than), GE (greater than or equal), LT (less
than), LE (less than or equal), and AND operators.
The
expression can evaluate whether a value is an instance of a class,
using the
instanceof operator:
expression instanceof java.class.name
This
operator, similar to the Java
instanceof operator,
produces a Boolean value. In this example, the value is true if the
class to which the
expression value belongs meets
any of the following conditions:
- Is named java.class.name
- Is a direct or indirect subclass of the class identified by java.class.name.
- Implements, directly or indirectly, the interface identified by java.class.name.
The expression can also instantiate a new object of a Java class, using the
new operator.
This operator is similar to the Java
new operator:
new java.class.name(expression1, expression2, ... expressionN)
Operator precedence
Operators are evaluated
in order of precedence. Operators of the same order of precedence
are evaluated from left to right. You can change the order of evaluation
by using parentheses
( and
).
The
order of precedence is:
- . operator (method call or field reference)
- [ ] (array element selector)
- new
- !, NOT
- *, /
- +, -
- GT, >, LT, <, GE, >=, LE, <=, instanceof
- ==, !=
- AND, &
- OR, |
Example
$s1 >= ( 2 * ($s2.sampMethod($s3, true) + 1))
The
agent evaluates this expression in the following way:
- The $s1 symbol is evaluated. It must
yield a numeric value.
- The $s2 symbol is evaluated. It must yield a Java object.
- The $s3 symbol is evaluated.
- The method sampMethod for the object
resulting from the evaluation of $s2 is called.
The result of the evaluation of $s3 is passed as
the first parameter, and the Boolean value true is
passed as the second parameter. The call to sampMethod must
return a numeric value.
- 1 is added to the result of step 4.
- The result of step 5 is multiplied by 2.
- The result of step 1 is
compared with the result of step 6. If the result of step 1 is greater than or equal
to the result of step 6, true is
returned. Otherwise, false is returned.