public class NumericEvaluator extends Object implements ExpressionEvaluator
T-Plan Robot Enterprise, (C) 2009-2022 T-Plan Limited. All rights reserved.
Modifier and Type | Field and Description |
---|---|
static String[] |
BOOLEAN_OPERATORS |
static String[] |
NUMERIC_OPERATORS |
static String |
OPERATOR_AND |
static String |
OPERATOR_CONTAINS |
static String |
OPERATOR_DIVIDE |
static String |
OPERATOR_ENDSWITH |
static String |
OPERATOR_EQUALS |
static String |
OPERATOR_EQUALS_NOT |
static String |
OPERATOR_EXISTS |
static String |
OPERATOR_GREATER_THAN |
static String |
OPERATOR_LEFT_PARENTHESIS |
static String |
OPERATOR_LOWER_THAN |
static String |
OPERATOR_MATCHES |
static String |
OPERATOR_MINUS |
static String |
OPERATOR_MODULO |
static String |
OPERATOR_MULTIPLY |
static String |
OPERATOR_OR |
static String |
OPERATOR_PLUS |
static String |
OPERATOR_RIGHT_PARENTHESIS |
static String |
OPERATOR_STARTSWITH |
static String[] |
UNARY_OPERATORS |
Constructor and Description |
---|
NumericEvaluator() |
Modifier and Type | Method and Description |
---|---|
Object |
evaluateNumericExpression(String expression,
Class resultType)
Evaluate an expression and return the result of the requested result
type.
|
Object |
evaluateNumericExpression(String expression,
Class resultType,
ScriptingContext context)
Evaluate an expression and return the result of the requested result
type.
|
String |
fixForCondition(String expression,
String forVariableName,
ScriptingContext context)
Fix improper variable calls in a condition which is to be processed using
the 'for' statement.
|
String |
fixIfCondition(String expression,
ScriptingContext context)
Fix improper variable calls in a condition which is to be processed using
the 'if' statement.
|
String[] |
getBinaryOperators() |
boolean |
isLegacy()
Indicate whether the back end parser is the legacy one.
|
boolean |
isOperator(String s) |
static void |
main(String[] args) |
List |
parseExpression(String expression) |
void |
test() |
public static final String OPERATOR_LEFT_PARENTHESIS
public static final String OPERATOR_RIGHT_PARENTHESIS
public static final String OPERATOR_PLUS
public static final String OPERATOR_MINUS
public static final String OPERATOR_MULTIPLY
public static final String OPERATOR_MODULO
public static final String OPERATOR_DIVIDE
public static final String OPERATOR_EQUALS
public static final String OPERATOR_EQUALS_NOT
public static final String OPERATOR_AND
public static final String OPERATOR_OR
public static final String OPERATOR_GREATER_THAN
public static final String OPERATOR_LOWER_THAN
public static final String OPERATOR_EXISTS
public static final String OPERATOR_CONTAINS
public static final String OPERATOR_STARTSWITH
public static final String OPERATOR_ENDSWITH
public static final String OPERATOR_MATCHES
public static final String[] NUMERIC_OPERATORS
public static final String[] BOOLEAN_OPERATORS
public static final String[] UNARY_OPERATORS
public Object evaluateNumericExpression(String expression, Class resultType)
ExpressionEvaluator
IllegalArgumentException
.evaluateNumericExpression
in interface ExpressionEvaluator
expression
- an expression such as "1+1" or "5==3 || 3>2".resultType
- the target result type. If Boolean.class is passed the
expression will be evaluated as a boolean expression. Otherwise the
method must return the numeric return type, for example Double.class or
Integer.class.public Object evaluateNumericExpression(String expression, Class resultType, ScriptingContext context)
ExpressionEvaluator
IllegalArgumentException
.evaluateNumericExpression
in interface ExpressionEvaluator
expression
- an expression such as "1+1" or "5==3 || 3>2".resultType
- the target result type. If Boolean.class is passed the
expression will be evaluated as a boolean expression. Otherwise the
method must return the numeric return type, for example Double.class or
Integer.class.context
- the script context. It is used for certain operators such
as 'exists [variable]'.public String[] getBinaryOperators()
public boolean isOperator(String s)
public static void main(String[] args)
public void test()
public String fixIfCondition(String expression, ScriptingContext context)
ExpressionEvaluator
fixIfCondition
in interface ExpressionEvaluator
expression
- an expression.context
- the script context.public String fixForCondition(String expression, String forVariableName, ScriptingContext context)
ExpressionEvaluator
fixForCondition
in interface ExpressionEvaluator
expression
- an expression.forVariableName
- optional name of the variable the 'for' loop
iterates on.context
- the script context.public boolean isLegacy()
ExpressionEvaluator
isLegacy
in interface ExpressionEvaluator