1.0 - Criteria Expression Reference - Vantage Customer Experience

Vantage Customer Experience User Guide

prodname
Vantage Customer Experience
vrm_release
1.0
category
User Guide
featnum
B035-3800-099K

This section describes all of the criteria functions in alphabetical order. The most powerful function and the one that you use most often when building expressions for criterion is get. That section contains the bulk of information about criteria expressions.

The criteria expression functions are similar to JavaScript. Users who write criteria expressions should have an understanding of JavaScript, the Java Pattern class, and regular expressions.

You can use the ! (not) operator in criteria expressions. The following is an example:

!(get("Customer.general.height") == "short")

This could also be expressed as shown in the following example:

get("Customer.general.height") != "short"
The Java Expression Parser(JEP) math functions are fully supported in the criteria engine. The following are the supported functions:
boolean ruleResult = getRulesResult("2 + 3 == 5");
assertTrue(ruleResult);
ruleResult = getRulesResult("2 * 3 == 6");
assertTrue(ruleResult);
ruleResult = getRulesResult("12 / 3 == 4");
assertTrue(ruleResult);
ruleResult = getRulesResult("12 - 3 == 9");
assertTrue(ruleResult);
ruleResult = getRulesResult("2 ^ 3 == 8");
assertTrue(ruleResult);
ruleResult = getRulesResult(" 1 - 3 == -2");
assertTrue(ruleResult);
ruleResult = getRulesResult(" 5 - 3 != 3");
assertTrue(ruleResult);
ruleResult = getRulesResult(" 1 - 3 == -2 && 5 - 3 != 3");
assertTrue(ruleResult);
ruleResult = getRulesResult(" 1 - 3 == 5 || 5 - 3 != 3");
assertTrue(ruleResult);
ruleResult = getRulesResult("! (2 == 3)");
assertTrue(ruleResult);
ruleResult = getRulesResult("sqrt(16)== 4");
assertTrue(ruleResult);
String expr = " set(\"attr\", 25) && (sqrt(get(\"attr\")) == 5) ";
ruleResult = getRulesResult(expr);
assertTrue(ruleResult);
expr = " set(\"attr\", 20) && (get(\"attr\") + get(\"attr\") == get(\"attr\")*2) ";
ruleResult = getRulesResult(expr);
assertTrue(ruleResult);
ruleResult = getRulesResult("ln(1)== 0");
assertTrue(ruleResult);
ruleResult = getRulesResult("log(100)== 2");
assertTrue(ruleResult);
ruleResult = getRulesResult("mod(26,3) == 2");
assertTrue(ruleResult);
ruleResult = getRulesResult("26 % 3 == 2");
assertTrue(ruleResult);
ruleResult = getRulesResult("abs(-26) == 26");
assertTrue(ruleResult);
ruleResult = getRulesResult("rand() > 0");
assertTrue(ruleResult);
ruleResult = getRulesResult("sin(0) == 0");
assertTrue(ruleResult);
ruleResult = getRulesResult("cos(0) == 1");
assertTrue(ruleResult);
ruleResult = getRulesResult("sin(3.14/2) < 1 && sin(3.14/2) > 0.95");
assertTrue(ruleResult);
ruleResult = getRulesResult("cos(3.14/2) > 0 && cos(3.14/2) < 0.05");
assertTrue(ruleResult);
ruleResult = getRulesResult("sum([16,20,20]) == 56");
assertTrue(ruleResult);