T-Plan Robot Enterprise 4.0.1
Build No. 4.0.1-20141118.1

com.tplan.robot.scripting
Class NumericEvaluator

java.lang.Object
  extended by com.tplan.robot.scripting.NumericEvaluator
Direct Known Subclasses:
JavaTestScriptMethodMapper, TokenParserImpl

public class NumericEvaluator
extends java.lang.Object

Parser and evaluator of numeric and boolean expressions as is defined in the Numeric Expressions and Boolean Expressions chapters of the T-Plan Robot Enterprise language specification.


T-Plan Robot Enterprise, (C) 2009-2014 T-Plan Limited. All rights reserved.


Field Summary
static java.lang.String[] BOOLEAN_OPERATORS
           
protected  java.util.Map booleanOperators
           
protected  boolean debug
           
static java.lang.String[] NUMERIC_OPERATORS
           
protected  java.util.Map numericOperators
           
static java.lang.String OPERATOR_AND
           
static java.lang.String OPERATOR_CONTAINS
           
static java.lang.String OPERATOR_DIVIDE
           
static java.lang.String OPERATOR_ENDSWITH
           
static java.lang.String OPERATOR_EQUALS
           
static java.lang.String OPERATOR_EQUALS_NOT
           
static java.lang.String OPERATOR_EXISTS
           
static java.lang.String OPERATOR_GREATER_THAN
           
static java.lang.String OPERATOR_LEFT_PARENTHESIS
           
static java.lang.String OPERATOR_LOWER_THAN
           
static java.lang.String OPERATOR_MATCHES
           
static java.lang.String OPERATOR_MINUS
           
static java.lang.String OPERATOR_MODULO
           
static java.lang.String OPERATOR_MULTIPLY
           
static java.lang.String OPERATOR_OR
           
static java.lang.String OPERATOR_PLUS
           
static java.lang.String OPERATOR_RIGHT_PARENTHESIS
           
static java.lang.String OPERATOR_STARTSWITH
           
protected  java.util.Map operators
           
static java.lang.String[] UNARY_OPERATORS
           
protected  java.util.Map unaryOperators
           
 
Constructor Summary
NumericEvaluator()
           
 
Method Summary
protected  java.lang.Object convertResult(java.lang.Object lastStackItem, java.lang.Class resultType, boolean isSingleOperandExpression)
           
protected  java.lang.Object convertResult(java.lang.Object lastStackItem, java.lang.Class resultType, boolean isSingleOperandExpression, boolean ignoreVariableCalls)
           
protected  void debug(java.util.Stack vars, java.util.Stack ops, java.lang.Object token)
           
protected  java.lang.String endsWithOperator(java.lang.String s)
           
protected  java.lang.Object evaluate(java.lang.Object var1, java.lang.Object var2, java.lang.Object operand, ScriptingContext context)
           
protected  java.lang.Object evaluate(java.lang.Object var1, java.lang.Object var2, java.lang.Object operand, ScriptingContext context, boolean ignoreVariableCalls)
           
 java.lang.Object evaluateNumericExpression(java.lang.String expression, java.lang.Class resultType)
           
 java.lang.Object evaluateNumericExpression(java.lang.String expression, java.lang.Class resultType, ScriptingContext context)
           
 java.lang.String[] getBinaryOperators()
           
 boolean isOperator(java.lang.String s)
           
protected  boolean isUnary(java.lang.Object op)
           
 java.util.List parseExpression(java.lang.String expression)
           
 void test()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OPERATOR_LEFT_PARENTHESIS

public static final java.lang.String OPERATOR_LEFT_PARENTHESIS
See Also:
Constant Field Values

OPERATOR_RIGHT_PARENTHESIS

public static final java.lang.String OPERATOR_RIGHT_PARENTHESIS
See Also:
Constant Field Values

OPERATOR_PLUS

public static final java.lang.String OPERATOR_PLUS
See Also:
Constant Field Values

OPERATOR_MINUS

public static final java.lang.String OPERATOR_MINUS
See Also:
Constant Field Values

OPERATOR_MULTIPLY

public static final java.lang.String OPERATOR_MULTIPLY
See Also:
Constant Field Values

OPERATOR_MODULO

public static final java.lang.String OPERATOR_MODULO
See Also:
Constant Field Values

OPERATOR_DIVIDE

public static final java.lang.String OPERATOR_DIVIDE
See Also:
Constant Field Values

OPERATOR_EQUALS

public static final java.lang.String OPERATOR_EQUALS
See Also:
Constant Field Values

OPERATOR_EQUALS_NOT

public static final java.lang.String OPERATOR_EQUALS_NOT
See Also:
Constant Field Values

OPERATOR_AND

public static final java.lang.String OPERATOR_AND
See Also:
Constant Field Values

OPERATOR_OR

public static final java.lang.String OPERATOR_OR
See Also:
Constant Field Values

OPERATOR_GREATER_THAN

public static final java.lang.String OPERATOR_GREATER_THAN
See Also:
Constant Field Values

OPERATOR_LOWER_THAN

public static final java.lang.String OPERATOR_LOWER_THAN
See Also:
Constant Field Values

OPERATOR_EXISTS

public static final java.lang.String OPERATOR_EXISTS
See Also:
Constant Field Values

OPERATOR_CONTAINS

public static final java.lang.String OPERATOR_CONTAINS
See Also:
Constant Field Values

OPERATOR_STARTSWITH

public static final java.lang.String OPERATOR_STARTSWITH
See Also:
Constant Field Values

OPERATOR_ENDSWITH

public static final java.lang.String OPERATOR_ENDSWITH
See Also:
Constant Field Values

OPERATOR_MATCHES

public static final java.lang.String OPERATOR_MATCHES
See Also:
Constant Field Values

NUMERIC_OPERATORS

public static final java.lang.String[] NUMERIC_OPERATORS

BOOLEAN_OPERATORS

public static final java.lang.String[] BOOLEAN_OPERATORS

UNARY_OPERATORS

public static final java.lang.String[] UNARY_OPERATORS

debug

protected boolean debug

operators

protected java.util.Map operators

numericOperators

protected java.util.Map numericOperators

booleanOperators

protected java.util.Map booleanOperators

unaryOperators

protected java.util.Map unaryOperators
Constructor Detail

NumericEvaluator

public NumericEvaluator()
Method Detail

evaluateNumericExpression

public java.lang.Object evaluateNumericExpression(java.lang.String expression,
                                                  java.lang.Class resultType)

evaluateNumericExpression

public java.lang.Object evaluateNumericExpression(java.lang.String expression,
                                                  java.lang.Class resultType,
                                                  ScriptingContext context)

isUnary

protected boolean isUnary(java.lang.Object op)

debug

protected void debug(java.util.Stack vars,
                     java.util.Stack ops,
                     java.lang.Object token)

convertResult

protected java.lang.Object convertResult(java.lang.Object lastStackItem,
                                         java.lang.Class resultType,
                                         boolean isSingleOperandExpression)

convertResult

protected java.lang.Object convertResult(java.lang.Object lastStackItem,
                                         java.lang.Class resultType,
                                         boolean isSingleOperandExpression,
                                         boolean ignoreVariableCalls)

evaluate

protected java.lang.Object evaluate(java.lang.Object var1,
                                    java.lang.Object var2,
                                    java.lang.Object operand,
                                    ScriptingContext context)

evaluate

protected java.lang.Object evaluate(java.lang.Object var1,
                                    java.lang.Object var2,
                                    java.lang.Object operand,
                                    ScriptingContext context,
                                    boolean ignoreVariableCalls)

getBinaryOperators

public java.lang.String[] getBinaryOperators()

endsWithOperator

protected java.lang.String endsWithOperator(java.lang.String s)

isOperator

public boolean isOperator(java.lang.String s)

parseExpression

public java.util.List parseExpression(java.lang.String expression)

test

public void test()

T-Plan Robot Enterprise 4.0.1
Build No. 4.0.1-20141118.1