Defining an expression
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
- 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
nullconstant
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
- Boolean operators:
AND,&,OR,|,NOT,! - Comparison:
==,!=,GT,>,LT,<,GE,>=,LE,<= - Numeric operators:
+,-,*,/ - Parentheses to force order of evaluation:
(,)
<,
>, 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.instanceof
operator:expression instanceof java.class.nameThis
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.
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 )..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
$s1symbol is evaluated. It must yield a numeric value. - The
$s2symbol is evaluated. It must yield a Java object. - The
$s3symbol is evaluated. - The
sampMethodmethod for the object that results from the evaluation of$s2is called. The result of the evaluation of$s3is passed as the first parameter, and the Boolean valuetrueis passed as the second parameter. The call tosampMethodmust 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,
trueis returned. Otherwise,falseis returned.