ERXBooleanExpressionParser Class Reference

Collaboration diagram for ERXBooleanExpressionParser:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 ERXBooleanExpressionParser (String expression)
boolean evaluateWithObject (NSKeyValueCodingAdditions valueProvider)
EOQualifier qualifier ()
String toDebugString ()
String toString ()

Private Member Functions

boolean isBooleanWordToken (String token)
String qualifierFormatForBooleanExpression ()

Private Attributes

EOQualifier _qualifier
String _qualifierFormatForBooleanExpression
final String expression

Static Private Attributes

static final String[] BOOLEAN_WORDS = new String[] { "AND", "OR", "NOT" }
static Pattern KEYPATH_TOKEN_PATTERN = Pattern.compile("\\w+([.]\\w*)*")


Detailed Description

Parses a boolean expression and evaluates that boolean expression against a valueProvider object that returns boolean values for the variable symbols found in the boolean expression.

The valueProvider object must implement NSKeyValueCodingAdditions interface.

Acceptable boolean expressions can use the words AND, OR and NOT in upper, lower or mixed case. Parentheses can be used as needed to group elements of the expression.

Variable symbols in the boolean expression can use characters and formatting of typical keys or keyPaths.

All other words besides AND, OR and NOT are assumed to be variables (aka keyPaths) which resolve to Boolean values when valueForKeyPath is invoked on the valueProvider object (which can be a NSDictionary of variable values or any object that implements NSKeyValueCodingAdditions)

For example Expression: (canViewPerson AND canEditPerson) OR (isTheBoss AND NOT account.isAccountDisabled)

Author:
kieran

Constructor & Destructor Documentation

ERXBooleanExpressionParser ( String  expression  ) 


Member Function Documentation

boolean evaluateWithObject ( NSKeyValueCodingAdditions  valueProvider  ) 

Returns:
the result of the boolean expression when evaluated with valueProvider

boolean isBooleanWordToken ( String  token  )  [private]

EOQualifier qualifier (  ) 

Returns:
the EOQualifier resulting from the boolean expression. Leaving this as public since it is useful for debugging the expression morphing in WOComponents

String qualifierFormatForBooleanExpression (  )  [private]

Returns:
the boolean expression converted to a EOQualifier qualifier format

String toDebugString (  ) 

String toString (  ) 


Member Data Documentation

EOQualifier _qualifier [private]

final String [] BOOLEAN_WORDS = new String[] { "AND", "OR", "NOT" } [static, private]

final String expression [private]

Pattern KEYPATH_TOKEN_PATTERN = Pattern.compile("\\w+([.]\\w*)*") [static, private]


The documentation for this class was generated from the following file:

Generated on Sat May 26 06:43:12 2012 for Project Wonder by  doxygen 1.5.8