net.windward.util
Class SimpleEvaluator
java.lang.Object
|
+--net.windward.util.SimpleEvaluator
- public class SimpleEvaluator
- extends java.lang.Object
This will evaluateBoolean an expression and return a boolean result. It supports tokens of type:
- long - 123
- double - 123.45
- boolean - true
- String - "hi there" - supports the escape sequence \\"
It also supports the following operators:
- == eq : equals for any kind of token. String contents are compared in a case sensitive compare.
- != ne : not equals for any kind of token. String contents are compared in a case sensitive compare.
- < lt : arithmetic less than (warning - you must use < instead of < in the template
- > gt : arithmetic greater than
- <= le : arithmetic less than or equal (warning - you must use <= instead of <= in the template
- >= ge : arithmetic greater than or equal
- && and : boolean and
- || or : boolean or
- ! not : boolean not
- + : arithimetic add
- - : arithimetic minus (supports unary operations too)
- * : arithimetic multiply
- /; div : arithimetic divide
- %; mod : arithimetic modulus
- () : paranthesis to force evaluation order.
This class does not support variables. The passed in string must be literals and operators only.
- Version:
- 1.0 Nov 26, 2003
|
Field Summary |
static java.lang.String |
CIRCULAR
Uses a circular reference |
static java.lang.String |
DIV_0
Divide by 0 in an evaluation. |
static java.lang.String |
NO_VALUE
Need a number and the cell is empty. |
static java.lang.String |
NOT_A_NUMBER
The number got too large or small |
static java.lang.String |
UNKNOWN_CELL
getValue() was asked for a reference that does not exist or makes no sense. |
static java.lang.String |
WRONG_TYPE
The wrong type of argument like "dave" + 3. |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
DIV_0
public static final java.lang.String DIV_0
- Divide by 0 in an evaluation.
UNKNOWN_CELL
public static final java.lang.String UNKNOWN_CELL
- getValue() was asked for a reference that does not exist or makes no sense.
NOT_A_NUMBER
public static final java.lang.String NOT_A_NUMBER
- The number got too large or small
WRONG_TYPE
public static final java.lang.String WRONG_TYPE
- The wrong type of argument like "dave" + 3.
NO_VALUE
public static final java.lang.String NO_VALUE
- Need a number and the cell is empty.
CIRCULAR
public static final java.lang.String CIRCULAR
- Uses a circular reference
SimpleEvaluator
public SimpleEvaluator()
evaluateBoolean
public static boolean evaluateBoolean(java.lang.String expr,
SimpleEvaluator.VariableEval evaluator)
evaluate
public static java.lang.Object evaluate(java.lang.String expr,
SimpleEvaluator.VariableEval evaluator)
main
public static void main(java.lang.String[] args)
Copyright © 2002 - 2008 Windward Reports - All Rights Reserved. java reporting software