net.wotonomy.control
Class EOQualifier

java.lang.Object
  extended by net.wotonomy.control.EOQualifier
Direct Known Subclasses:
EOAndQualifier, EOKeyComparisonQualifier, EOKeyValueQualifier, EONotQualifier, EOOrQualifier

public abstract class EOQualifier
extends java.lang.Object

EOQualifiers are used to perform property-based qualifications on objects: for a set of criteria, a qualifier either qualifies or disqualifies an given object. EOKeyValueQualifiers can be joined by EOAndQualifier and EOOrQualifier, and so can form a tree of qualifications.

Certain qualifiers can accept a variable in place of a value; variable names are marked by a "$", as in "$name". Variables are resolved with the qualifierWithBindings() method.

Version:
$Revision: 894 $
Author:
michael@mpowers.net, yjcheung@intersectsoft.com, $Author: cgruber $

Field Summary
static net.wotonomy.foundation.NSSelector QualifierOperatorCaseInsensitiveLike
           
static net.wotonomy.foundation.NSSelector QualifierOperatorContains
           
static net.wotonomy.foundation.NSSelector QualifierOperatorEqual
           
static net.wotonomy.foundation.NSSelector QualifierOperatorGreaterThan
           
static net.wotonomy.foundation.NSSelector QualifierOperatorGreaterThanOrEqualTo
           
static net.wotonomy.foundation.NSSelector QualifierOperatorLessThan
           
static net.wotonomy.foundation.NSSelector QualifierOperatorLessThanOrEqualTo
           
static net.wotonomy.foundation.NSSelector QualifierOperatorLike
           
static net.wotonomy.foundation.NSSelector QualifierOperatorNotEqual
           
 
Constructor Summary
EOQualifier()
          Default constructor.
 
Method Summary
 void addQualifierKeysToSet(java.util.Set aSet)
          Adds all qualifier keys in this qualifier to the specified Set, which is expected to be mutable.
 net.wotonomy.foundation.NSSet allQualifierKeys()
          Returns a Set of all property names used for comparisons by this qualifier.
static net.wotonomy.foundation.NSArray allQualifierOperators()
          Returns a List of valid operators.
 net.wotonomy.foundation.NSArray bindingKeys()
          Returns a List containing the variables used at compare-time by this qualifier.
static java.lang.Object decodeWithKeyValueUnarchiver(EOKeyValueUnarchiver ua)
           
 boolean evaluateWithObject(java.lang.Object anObject)
          Returns whether the specified object meets the criteria defined by this qualifier.
static void filterArrayWithQualifier(java.util.List anObjectList, EOQualifier aQualifier)
          Convenience to retain only those objects from the specified List that meet the specified qualifier's requirements.
static net.wotonomy.foundation.NSArray filteredArrayWithQualifier(java.util.List anObjectList, EOQualifier aQualifier)
          Convenience to return a List consisting only of those objects in the specified List that meet the specified qualifier's requirements.
 java.lang.String keyPathForBindingKey(java.lang.String aVariable)
          Returns the key (which can be a key path) that is tested against the specified binding variable.
static net.wotonomy.foundation.NSSelector operatorSelectorForString(java.lang.String anOperatorString)
          Returns a selector the corresponds to the operation represented by the specified string.
static EOQualifier qualifierToMatchAllValues(java.util.Map aMap)
          Convenience to create a set of EOKeyValueQualifiers joined by an EOAndQualifier.
static EOQualifier qualifierToMatchAnyValue(java.util.Map aMap)
          Convenience to create a set of EOKeyValueQualifiers joined by an EOOrQualifier.
 EOQualifier qualifierWithBindings(java.util.Map aMap, boolean requireAll)
          Returns a qualifier that is like this qualifier, except all variables will be replaced with values from the specified Map whose keys match the variable names.
static EOQualifier qualifierWithQualifierFormat(java.lang.String aString, java.util.List anArgumentList)
          Returns an EOQualifier that meets the criteria represented by the specified string and variable length argument list.
static net.wotonomy.foundation.NSArray relationalQualifierOperators()
          Returns a List of operators that are supported for relational operations.
static java.lang.String stringForOperatorSelector(net.wotonomy.foundation.NSSelector aSelector)
          Returns a string the corresponds to the operation represented by the specified selector.
 java.lang.String toString()
          Returns a string representation of this qualifier.
 java.lang.Throwable validateKeysWithRootClassDescription(java.lang.Class aClass)
          Tests whether all the keys in this qualifier can be applied to an object of the specified class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

QualifierOperatorCaseInsensitiveLike

public static final net.wotonomy.foundation.NSSelector QualifierOperatorCaseInsensitiveLike

QualifierOperatorContains

public static final net.wotonomy.foundation.NSSelector QualifierOperatorContains

QualifierOperatorEqual

public static final net.wotonomy.foundation.NSSelector QualifierOperatorEqual

QualifierOperatorGreaterThan

public static final net.wotonomy.foundation.NSSelector QualifierOperatorGreaterThan

QualifierOperatorGreaterThanOrEqualTo

public static final net.wotonomy.foundation.NSSelector QualifierOperatorGreaterThanOrEqualTo

QualifierOperatorLessThan

public static final net.wotonomy.foundation.NSSelector QualifierOperatorLessThan

QualifierOperatorLessThanOrEqualTo

public static final net.wotonomy.foundation.NSSelector QualifierOperatorLessThanOrEqualTo

QualifierOperatorLike

public static final net.wotonomy.foundation.NSSelector QualifierOperatorLike

QualifierOperatorNotEqual

public static final net.wotonomy.foundation.NSSelector QualifierOperatorNotEqual
Constructor Detail

EOQualifier

public EOQualifier()
Default constructor.

Method Detail

addQualifierKeysToSet

public void addQualifierKeysToSet(java.util.Set aSet)
Adds all qualifier keys in this qualifier to the specified Set, which is expected to be mutable. The tree of qualifiers is traversed and the left-hand-side of each expression is added to the set.


allQualifierKeys

public net.wotonomy.foundation.NSSet allQualifierKeys()
Returns a Set of all property names used for comparisons by this qualifier. The tree of qualifiers is traversed and the left-hand-side of each expression is added to the set.


bindingKeys

public net.wotonomy.foundation.NSArray bindingKeys()
Returns a List containing the variables used at compare-time by this qualifier. Each variable will appear only once in the list.


evaluateWithObject

public boolean evaluateWithObject(java.lang.Object anObject)
Returns whether the specified object meets the criteria defined by this qualifier.


keyPathForBindingKey

public java.lang.String keyPathForBindingKey(java.lang.String aVariable)
Returns the key (which can be a key path) that is tested against the specified binding variable. The tree is traversed looking for the first instance of the specified variable, and the corresponding left-hand-side of the expression is returned.


qualifierWithBindings

public EOQualifier qualifierWithBindings(java.util.Map aMap,
                                         boolean requireAll)
Returns a qualifier that is like this qualifier, except all variables will be replaced with values from the specified Map whose keys match the variable names. If requireAll is true, an exception will be thrown if there is no key that matches on of the variables in the tree; otherwise, the qualifier containing the unmatched variable is removed.


validateKeysWithRootClassDescription

public java.lang.Throwable validateKeysWithRootClassDescription(java.lang.Class aClass)
Tests whether all the keys in this qualifier can be applied to an object of the specified class.

Returns:
A Throwable if the validation fails, otherwise returns null if the class can be used with this qualifier.

filterArrayWithQualifier

public static void filterArrayWithQualifier(java.util.List anObjectList,
                                            EOQualifier aQualifier)
Convenience to retain only those objects from the specified List that meet the specified qualifier's requirements.


filteredArrayWithQualifier

public static net.wotonomy.foundation.NSArray filteredArrayWithQualifier(java.util.List anObjectList,
                                                                         EOQualifier aQualifier)
Convenience to return a List consisting only of those objects in the specified List that meet the specified qualifier's requirements.


qualifierToMatchAllValues

public static EOQualifier qualifierToMatchAllValues(java.util.Map aMap)
Convenience to create a set of EOKeyValueQualifiers joined by an EOAndQualifier. Each pair of keys and values are used to create EOKeyValueQualifiers.


qualifierToMatchAnyValue

public static EOQualifier qualifierToMatchAnyValue(java.util.Map aMap)
Convenience to create a set of EOKeyValueQualifiers joined by an EOOrQualifier. Each pair of keys and values are used to create EOKeyValueQualifiers.


qualifierWithQualifierFormat

public static EOQualifier qualifierWithQualifierFormat(java.lang.String aString,
                                                       java.util.List anArgumentList)
Returns an EOQualifier that meets the criteria represented by the specified string and variable length argument list. This method parses the string and returns a tree of qualifiers. Each token beginning with "%" is replaced with the corresponding object from the argument list. The parser recognizes the operation tokens returned from the allQualifierOperators() method.


relationalQualifierOperators

public static net.wotonomy.foundation.NSArray relationalQualifierOperators()
Returns a List of operators that are supported for relational operations. This excludes string comparison operators.


allQualifierOperators

public static net.wotonomy.foundation.NSArray allQualifierOperators()
Returns a List of valid operators.


operatorSelectorForString

public static net.wotonomy.foundation.NSSelector operatorSelectorForString(java.lang.String anOperatorString)
Returns a selector the corresponds to the operation represented by the specified string. For example, ">" represents QualifierOperatorGreaterThan.


stringForOperatorSelector

public static java.lang.String stringForOperatorSelector(net.wotonomy.foundation.NSSelector aSelector)
Returns a string the corresponds to the operation represented by the specified selector. For example, QualifierOperatorGreaterThan is represented with ">".


toString

public java.lang.String toString()
Returns a string representation of this qualifier.

Overrides:
toString in class java.lang.Object

decodeWithKeyValueUnarchiver

public static java.lang.Object decodeWithKeyValueUnarchiver(EOKeyValueUnarchiver ua)


Copyright © 2006 null. All Rights Reserved.