- Inherits from:
- (com.apple.client.eocontrol) Object
(com.apple.yellow.eocontrol) NSObject
- Package:
- com.apple.client.eocontrol
- com.apple.yellow.eocontrol
EOQualifier is an abstract class for objects that hold information used to restrict selections on objects or database rows according to specified criteria. With the exception of EOSQLQualifier (EOAccess), qualifiers aren't based on SQL and they don't rely upon an EOModel (EOAccess). Thus, the same qualifier can be used both to perform in-memory searches and to fetch from the database.
You never instantiate an instance of EOQualifier. Rather, you use one of its subclasses-one of the following or your own custom EOQualifier subclass:
Subclass | Purpose |
EOKeyValueQualifier | Compares the named property of an object to a supplied value, for example, "weight > 150". |
EOKeyComparisonQualifier | Compares the named property of one object with the named property of another, for example "name = wife.name". |
EOAndQualifier | Contains multiple qualifiers, which it conjoins. For example, "name = 'Fred' AND age < 20". |
EOOrQualifier | Contains multiple qualifiers, which it disjoins. For example, "name = 'Fred' OR name = 'Ethel'". |
EONotQualifier | Contains a single qualifier, which it negates. For example, "NOT (name = 'Fred')". |
EOSQLQualifier | Contains unstructured text that can be transformed into a SQL expression. EOSQLQualifier provides a way to create SQL expressions with any arbitrary SQL. Because EOSQLQualifiers can't be evaluated against objects in memory and because they contain database and SQL-specific content, you should use EOQualifier wherever possible. |
The interface EOQualifierEvaluation defines how qualifiers are evaluated in memory. To evaluate qualifiers in a database, methods in EOSQLExpression (EOAccess) and EOEntity (EOAccess) are used to generate SQL for qualifiers. Note that all of the SQL generation functionality is contained in the access layer.
For more information on using EOQualifiers, see the sections
EOQualifier defines the following NSSelector constants to represent the qualifier operators:
- Creating a qualifier
- qualifierWithQualifierFormat (com.apple.yellow.eocontrol only)
- qualifierToMatchAllValues
- qualifierToMatchAnyValue
- qualifierWithBindings
- In-memory filtering
- filterArrayWithQualifier
- filteredArrayWithQualifier
- evaluateWithObject
- Converting strings and operators
- operatorSelectorForString
- stringForOperatorSelector
- Get EOQualifier operators
- allQualifierOperators
- relationalQualifierOperators
- Accessing a qualifiers keys
- allQualifierKeys
- addQualifierKeysToSet:
- Accessing a qualifier's binding keys
- bindingKeys
- keyPathForBindingKey
- Validating a qualifier's keys
- validateKeysWithRootClassDescription
public static NSArray
allQualifierOperators
()
See Also: relationalQualifierOperators
public static void
filterArrayWithQualifier
(
NSMutableArray objects,
EOQualifier aQualifier)
public static NSArray
filteredArrayWithQualifier
(
NSArray objects,
EOQualifier aQualifier)
public static NSSelector
operatorSelectorForString
(String aString)
.Selector selector = Qualifier.operatorSelectorForString("!=");
The possible values of aString are =, ==, !=, <, >, <=, >=, "like", and "caseInsensitiveLike".
You'd probably only use this method if you were writing your own qualifier parser.
See Also: stringForOperatorSelector
public static EOQualifier
qualifierToMatchAllValues
(NSDictionary dictionary)
public static EOQualifier
qualifierToMatchAnyValue
(NSDictionary dictionary)
public static EOQualifier
qualifierWithQualifierFormat
(
String qualifierFormat,
NSArray arguments)
Based on the content of qualifierFormat,
this method generates a tree of the basic qualifier types. For example,
the format string "firstName = 'Joe' AND department = 'Facilities'"
generates an EOAndQualifier that contains two "sub" EOKeyValueQualifiers.
The following code excerpt shows a typical way to use the qualifierWithQualifierFormat
method.
The excerpt constructs an EOFetchSpecification, which includes an
entity name and a qualifier. It then applies the EOFetchSpecification
to the EODisplayGroup's data source and tells the EODisplayGroup
to fetch.
EODisplayGroup displayGroup; /* Assume this exists.*/ EOQualifier qualifier; EOFetchSpecification fetchSpec; EODatabaseDataSource dataSource; dataSource = (EODatabaseDataSource)displayGroup.dataSource(); qualifier = EOQualifier.qualifierWithQualifierFormat("cardType = 'Visa'", null); fetchSpec = new EOFetchSpecification("Member", qualifier, null), null); dataSource.setFetchSpecification(fetchSpec); displayGroup.fetch();
qualifierWithQualifierFormat
performs
no verification to ensure that keys referred to by the format string qualifierFormat exist.
It throws an exception if qualifierFormat contains
any syntax errors.
public static NSArray
relationalQualifierOperators
()
See Also: allQualifierOperators
public static String
stringForOperatorSelector
(NSSelector aSelector)
String operator = EOQualifier.stringForOperatorSelector(EOQualifier.QualifierOperatorNotEqual);
The possible values for selector are as follows:
You'd probably use this method only if you were writing your own parser.
See Also: operatorSelectorForString
public void
addQualifierKeysToSet
(NSMutableSet qualKeys)
Subclasses of EOQualifier must implement this method.
public NSSet
allQualifierKeys
()
salary > 10000 AND manager.lastName = 'smith'
allQualifierKeys
returns
an array containing the strings "salary" and "manager.lastName".
Subclasses should not override this method, instead they should override addQualifierKeysToSet:.
NSArray
bindingKeys
()
(com.apple.client.eocontrol) public boolean
evaluateWithObject
(EOKeyValueCodingAdditions object)
(com.apple.yellow.eocontrol) public boolean
evaluateWithObject
(Object object)
YES
if object matches
the criteria specified in the receiver, NO
otherwise.
The argument, object, should be an enterprise object, a snapshot
dictionary, or something that implements key-value coding.public String
keyPathForBindingKey
(String key)
keyPathForBindingKey
would
return salary for amount, and manager.lastname for manager.public abstract EOQualifier
qualifierWithBindings
(
NSDictionary bindings,
boolean requiresAll)
(com.apple.client.eocontrol) public abstract void
validateKeysWithRootClassDescription
(EOClassDescription classDesc)
null
to indicate
that the keys contained by the qualifier are valid.
(com.apple.yellow.eocontrol) public abstract Throwable
validateKeysWithRootClassDescription
(EOClassDescription classDesc)
null
to indicate
that the keys contained by the qualifier are valid.