|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--com.ibm.wbi.util.StructuredCondition
Used to parse, store, and evaluate a Boolean expression involving attribute-value pairs. It can handle arbitrary levels of parentheses, the operators & (boolean AND), | (boolean OR), and ! (unary boolean NOT).
The basic expressions for evaluating an attribute-value pair are: AttributeName = Value and AttributeName ~ Value. The '~' operator is a case-insensitive comparison. The Value can be the special value '%null%' which means that the given AttributeName should not be defined.
Values can also be expressed with a wildcard character(s). '*' at the beginning of the Value indicates that only the ends of the strings need match. Likewise, '*' at the end means only the beginnings of the strings need match. And '*' at both the beginning and end of the Value indicates that the Value only needs to be contained in the string.
Values can be enclosed within quotes (for example, "abc"). This allows characters that are normally treated as operators, such as &, to be included within a value. To enclose a quote within the quoted value, precede it with the backslash (\). If Java will parse the String, such as when you enter the String in Java code in double quotes or it is read from a properties file (persistent Section) such as one describing a MEG, you will need to use three backslashes:
"beforequote\\\"afterquote"
If the value is not within quotes, spaces are allowed within values, but not at either end. Thus "User-Agent=*Windows CE*" is allowed, while "User-Agent= Windows " would be treated the same as "User-Agent=Windows". To include spaces at the beginning or end of a value, enclose the value in quotes.
Two special boolean values, %true% and %false%, can also be used. For example, a condition that is always true is "%true%". Example conditions are:
| Constructor Summary | |
StructuredCondition()
Construct a new empty StructuredCondition. |
|
StructuredCondition(boolean compareAsLowerCaseOnly)
Construct a new empty StructuredCondition. |
|
| Method Summary | |
boolean |
getCompareAsLowerCaseOnly()
Returns the flag whether field values should be compared lower case only. |
java.lang.String |
getCondition()
Get the condition. |
java.util.Enumeration |
getFieldnames()
Get the field names references in the condition |
void |
setCondition(java.lang.String condition)
Set and parse the condition specified. |
void |
setCondition(java.lang.String condition,
java.lang.String[] allowedRules)
Set and parse the condition specified. |
void |
setCondition(java.lang.String condition,
java.lang.String[] allowedRules,
boolean caseSensitive)
Set and parse the condition specified. |
boolean |
solve(java.util.Dictionary d)
Determine if the condition solves the Attribute-Value pairs specified in the Dictionary parameter. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public StructuredCondition()
public StructuredCondition(boolean compareAsLowerCaseOnly)
compareAsLowerCaseOnly - Compares all values as lower case if
true, otherwise uses
case.| Method Detail |
public boolean getCompareAsLowerCaseOnly()
public void setCondition(java.lang.String condition)
throws IllegalConditionException
condition - The condition to parse.IllegalConditionException - If an error occurs parsing the
condition.
public void setCondition(java.lang.String condition,
java.lang.String[] allowedRules)
throws IllegalConditionException
allowedRules array.
If the array is of zero length, rules are not verified. The
rules are not case sensitive.condition - The condition to parse.allowedRules - An array of the rules (Attributes) allowed,
these rules may have wild cards, so for
example, a rule of "re*" would allow rules
such as "responseCode" or "requestHeader".IllegalConditionException - If an error occurs parsing the
condition or a rule is invalid.
public void setCondition(java.lang.String condition,
java.lang.String[] allowedRules,
boolean caseSensitive)
throws IllegalConditionException
allowedRules array.
If the array is of zero length, rules are not verified.condition - The condition to parse.allowedRules - An array of the rules (Attributes) allowed,
these rules may have wild cards, so for
example, a rule of "re*" would allow rules
such as "responseCode" or "requestHeader".caseSensitive - Determines if the rules should be verified
as case sensitive.IllegalConditionException - If an error occurs parsing the
condition or a rule is invalid.public java.lang.String getCondition()
public java.util.Enumeration getFieldnames()
public boolean solve(java.util.Dictionary d)
d - the Attribute-Value pairs to check against.true if condition "solves" Dictionary; else
false.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||