|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object edu.sdsc.inca.util.ExprEvaluator
public class ExprEvaluator
A simple top-down boolean expression evaluator. Supports the boolean binary operators <, <=, >, >=, ==, !=, <>, &&, and ||, as well as perl's pattern match (=~) and mismatch (!~) operators. Supports parenthesized sub-expressions. Operands may be any of: a quoted string literal; a numeric literal; a pattern literal enclosed in slashes; an identifier defined in the report body by an ID tag; a version literal composed of digits, letters, underscores and dots.
Field Summary | |
---|---|
static java.lang.String |
FAIL_EXPR_FAILED
Failure result values from eval. |
static java.lang.String |
FAIL_INVALID_OPERATOR
|
static java.lang.String |
FAIL_MISSING_OPERAND
|
static java.lang.String |
FAIL_MISSING_OPERATOR
|
static java.lang.String |
FAIL_MISSING_RPAREN
|
static java.lang.String |
FAIL_UNDEFINED_SYMBOL
|
protected static java.util.regex.Pattern |
OPERAND_PATTERN
Operands: a quoted or slash-surrounded literal or a symbol. |
Constructor Summary | |
---|---|
ExprEvaluator()
|
Method Summary | |
---|---|
protected static java.lang.String |
binary(java.lang.StringBuffer expr,
java.util.Properties symbols,
java.lang.String valueIfUndef)
Part of a simple top-down expression evaluator. |
protected static java.lang.String |
conjunction(java.lang.StringBuffer expr,
java.util.Properties symbols,
java.lang.String valueIfUndef)
Part of a simple top-down expression evaluator. |
static java.lang.String |
eval(java.lang.String expr,
java.util.Properties symbols,
java.lang.String valueIfUndef)
Evaluate a boolean expression given a set of symbols. |
protected static java.lang.String |
getOperand(java.lang.StringBuffer expr)
Part of a simple top-down expression evaluator. |
protected static java.lang.String |
parenthesized(java.lang.StringBuffer expr,
java.util.Properties symbols,
java.lang.String valueIfUndef)
Part of a simple top-down expression evaluator. |
protected static void |
skipSpaces(java.lang.StringBuffer sb)
Removes leading spaces from a StringBuffer. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static java.lang.String FAIL_EXPR_FAILED
public static java.lang.String FAIL_INVALID_OPERATOR
public static java.lang.String FAIL_MISSING_OPERAND
public static java.lang.String FAIL_MISSING_OPERATOR
public static java.lang.String FAIL_MISSING_RPAREN
public static java.lang.String FAIL_UNDEFINED_SYMBOL
protected static java.util.regex.Pattern OPERAND_PATTERN
Constructor Detail |
---|
public ExprEvaluator()
Method Detail |
---|
public static java.lang.String eval(java.lang.String expr, java.util.Properties symbols, java.lang.String valueIfUndef)
expr
- the expression to evaluatesymbols
- a table that associates symbol names with valuesvalueIfUndef
- the value to use for identifiers encountered in the
expression that have no value in the symbol table. If null, the
method throws an exception when it encounters an undefined symbol.
protected static java.lang.String conjunction(java.lang.StringBuffer expr, java.util.Properties symbols, java.lang.String valueIfUndef)
expr
- the expression to evaluatesymbols
- a table that associates symbol names with valuesvalueIfUndef
- the value to use for identifiers encountered in the
expression that have no value in the symbol table. If null, the
method throws an exception when it encounters an undefined symbol.
protected static java.lang.String parenthesized(java.lang.StringBuffer expr, java.util.Properties symbols, java.lang.String valueIfUndef)
expr
- the expression to evaluatesymbols
- a table that associates symbol names with valuesvalueIfUndef
- the value to use for identifiers encountered in the
expression that have no value in the symbol table. If null, the
method throws an exception when it encounters an undefined symbol.
protected static java.lang.String binary(java.lang.StringBuffer expr, java.util.Properties symbols, java.lang.String valueIfUndef)
expr
- the expression to evaluatesymbols
- a table that associates symbol names with valuesvalueIfUndef
- the value to use for identifiers encountered in the
expression that have no value in the symbol table. If null, the
method throws an exception when it encounters an undefined symbol.
protected static java.lang.String getOperand(java.lang.StringBuffer expr)
expr
- the expression to evaluate
protected static void skipSpaces(java.lang.StringBuffer sb)
sb
- the string buffer to trim
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |