Rules expressions
This topic defines syntax and semantics of expressions that are used in the predicate and assignment sections of the Rules.json file.
For an existing rule, you can view the content of the Rules.json file through .
Context
Expressions can occur in the predicate and assignment sections of rules, in the rules
property. This property is an object that has following four properties:
Property | Description |
---|---|
field |
Specified attribute path. |
operator |
Specifies the operator. |
value |
Value can be a number or text. Depends on the predicateType
property. |
predicateType |
Specifies the type of predicate. The type can be Value(Constant value), Attribute(Attribute path), Expression(either numeric or string), and Special(function). |
Syntax terms
- Numeric constant
- Sequence of digits that can optionally contain a decimal point.
- String constant
- Sequence of characters enclosed in single quotation marks.
- Attribute reference
- Attribute path enclosed in double quotation marks.
- Substring function
- Single token. The first argument of the string is attribute reference. Following function fetches substring from a string:
- Expression
- Either can be a numeric expression or a string expression. The expression type is determined by the type of first operand (same). The semantics of expressions correspond to their semantics in the IBM® Product Master script, which are equivalent to those of expressions in Java™.
- Operator precedence for numeric expressions is same.
- Type of an expression is attribute in the field property.
- All the tokens in an expression must be of the same type.
- A constant has the type and value of itself.
- An attribute reference has the type and value of the attribute at its path. The value can be null, or the attribute may not be defined for the path and the value is null. Operations on null values are not allowed.
- Numeric expression - Predicate
-
{ "field": "Search Ctg Spec/integer", "operator": "lessThan", "value": "2 * \"Search Ctg Spec/integer-RTS\"", "predicateType": "Expression" }
- Numeric expression - Assignment
-
{ "field": "Search Ctg Spec/integer", "operator": "equal", "value": "\"Search Ctg Spec/integer-RTS\" / 2 * 4.5 * (\"Search Ctg Spec/number-RTS\" - \"Search Ctg Spec/number\")", "predicateType": "Expression" }
- String expression - Predicate
-
{ "field": "Search Ctg Spec/string-RTS", "operator": "beginsWith", "value": "substring(\"Search Ctg Spec/string-RTS\", 3, 6) + 'abc'", "predicateType": "Expression" }
- String expression - Assignment
-
{ "field": "Search Ctg Spec/pk", "operator": "equal", "value": "'p\'qr' + \"Search Ctg Spec/string\"", "predicateType": "Expression" }