|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.sandev.basics.util.MatchUtil
public class MatchUtil
Simple match expression evaluation. This class allows you to compare a a value to an expression through recursive evaluation of the tokenized expression form. This is NOT intended for use in
| Constructor Summary | |
|---|---|
MatchUtil()
|
|
| Method Summary | |
|---|---|
static java.lang.String |
blend(java.lang.String attr,
java.lang.String val)
Given an attribute and a value in standard match expression form, convert the match expression to an infix form with the attribute specified. |
static boolean |
eval(java.util.Date val,
java.lang.String expr)
Return true if the given value matches the given expression, false otherwise. |
static boolean |
eval(java.util.Date val,
java.lang.String[] expr,
int index)
Return true if the given value matches the tokenized expression, false otherwise. |
static boolean |
eval(double val,
java.lang.String expr)
Return true if the given value matches the given expression, false otherwise. |
static boolean |
eval(double val,
java.lang.String[] expr,
int index)
Return true if the given value matches the tokenized expression, false otherwise. |
static boolean |
eval(int val,
java.lang.String expr)
Return true if the given value matches the given expression, false otherwise. |
static boolean |
eval(long val,
java.lang.String expr)
Return true if the given value matches the given expression, false otherwise. |
static boolean |
eval(long val,
java.lang.String[] expr,
int index)
Return true if the given value matches the tokenized expression, false otherwise. |
static boolean |
eval(java.lang.String val,
java.lang.String expr)
Return true if the given value matches the given expression, false otherwise. |
static boolean |
eval(java.lang.String val,
java.lang.String[] expr,
int index)
Return true if the given value matches the tokenized expression, false otherwise. |
static java.lang.String |
fixEnumVal(java.lang.String value,
java.lang.String[] printVals,
java.lang.String[] keyVals,
java.lang.String[] actualVals)
Read the given value, tokenizing as appropriate, and convert any key or print values back into their actual numeric values. |
static void |
insertImpliedEqualityOperators(java.util.ArrayList al)
Given a tokenized expression, insert any missing implied equality operators. |
static boolean |
isCompound(java.lang.String expr)
Return true if this is a compound expression, false otherwise. |
static boolean |
isConjunction(java.lang.String text)
Return true if the given text could be understood as an AND or OR conjunction operator, false otherwise. |
static boolean |
isEXOPCloseParen(SandAttrVal sav)
Return true if the given attrval is an EXOP close paren, false otherwise. |
static boolean |
isEXOPConjunction(SandAttrVal sav)
Return true if the given attrval is an AND or OR expression operation, false otherwise. |
static boolean |
isEXOPOpenParen(SandAttrVal sav)
Return true if the given attrval is an EXOP open paren, false otherwise. |
static boolean |
isOperator(java.lang.String oper)
Return true if this is a valid operator, false otherwise. |
static java.lang.String |
nextToken(java.util.StringTokenizer toker)
Given a StringTokenizer, return the next token taking into account quoted string values. |
static java.lang.String |
normalizeExprFormat(java.lang.String expr)
Return the normalized form of the expression so that the returned expression can be tokenized on whitespace. |
static int |
rangeDigitsInteger(java.lang.String rangeExpr,
int defaultVal)
Given an integer value range specification, return the likely number of digits necessary for display. |
static boolean |
startsWithOp(java.lang.String expr)
Returns true if the given expr string starts with an operator as defined by normalizeExprFormat. |
static java.lang.String[] |
tokenize(java.lang.String expr)
Given an expression, return an array of tokens. |
static java.lang.String |
unTokenize(java.lang.String[] tokens)
Concatenate the tokens together separated by a space. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public MatchUtil()
| Method Detail |
|---|
public static boolean eval(int val,
java.lang.String expr)
public static boolean eval(long val,
java.lang.String expr)
public static boolean eval(double val,
java.lang.String expr)
public static boolean eval(java.lang.String val,
java.lang.String expr)
public static boolean eval(java.util.Date val,
java.lang.String expr)
public static boolean eval(long val,
java.lang.String[] expr,
int index)
public static boolean eval(double val,
java.lang.String[] expr,
int index)
public static boolean eval(java.lang.String val,
java.lang.String[] expr,
int index)
public static boolean eval(java.util.Date val,
java.lang.String[] expr,
int index)
public static boolean isOperator(java.lang.String oper)
public static boolean isConjunction(java.lang.String text)
public static java.lang.String[] tokenize(java.lang.String expr)
public static void insertImpliedEqualityOperators(java.util.ArrayList al)
public static java.lang.String nextToken(java.util.StringTokenizer toker)
public static int rangeDigitsInteger(java.lang.String rangeExpr,
int defaultVal)
public static java.lang.String normalizeExprFormat(java.lang.String expr)
<, <=, >, >=, =, !=
AND, OR, NOT
This method may add additional whitespace around operators. Embedded whitespace is a possibility, and consuming methods must be prepared to handle any corresponding empty tokens from this formatting when tokenizing the resulting string on whitespace. This method ensures that operators are whitespace delimited, but does not trim whitespace or ensure minimum whitespace.
public static boolean startsWithOp(java.lang.String expr)
public static java.lang.String blend(java.lang.String attr,
java.lang.String val)
> 18 AND < 50
myAttr > 18 AND myAttr < 50
The value is assumed to be in normalized form so it can be tokenized on whitespace.
public static boolean isCompound(java.lang.String expr)
public static java.lang.String fixEnumVal(java.lang.String value,
java.lang.String[] printVals,
java.lang.String[] keyVals,
java.lang.String[] actualVals)
The tricky part about this is that "AND" and "OR" can be conjunction operators or they can be values to translate. So we need to distinguish between operator "OR" and abbreviation for the state of Oregon "OR". We do this by making sure that anything we expect to be a conjunction
"CA or OR" becomes "10 or 38"
"CA or OR or WA" becomes "10 or 38 or 48"
Many match expressions will not start with an operator.
printVals - The array of print values. For example:
"active", "deleted", "archived"keyVals - The array of key values, or constant names. For example:
"Task.RECORDSTATUS_ACTIVE", "Task.RECORDSTATUS_DELETED", "Task.RECORDSTATUS_ARCHIVED"actualVals - The array of actual numeric string values. For example:
"0", "1", "2"public static java.lang.String unTokenize(java.lang.String[] tokens)
public static boolean isEXOPConjunction(SandAttrVal sav)
public static boolean isEXOPOpenParen(SandAttrVal sav)
public static boolean isEXOPCloseParen(SandAttrVal sav)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||