EOKeyValueQualifier

Inherits From:
EOQualifier : NSObject

Conforms To: EOQualifierEvaluation
EOQualifierSQLGeneration

Declared in: EOControl/EOQualifier.h

Class Description

EOKeyValueQualifier is a subclass of EOQualifier that compares a named property of an object with a supplied value, for example, "salary > 1500". EOKeyValueQualifier adopts the EOQualifierEvaluation protocol, which defines the method evaluateWithObject: for in-memory evaluation. When an EOKeyValueQualifier object receives an evaluateWithObject: message, it evaluates the given object to determine if it satisfies the qualifier criteria.

In addition to performing in-memory filtering, EOKeyValueQualifier can be used to generate SQL. When it's used for this purpose, the key should be a valid property name of the root entity for the qualifier (or a valid key path).


Adopted Protocols

EOQualifierEvaluation
- evaluateWithObject:
EOQualifierSQLGeneration
- sqlStringForSQLExpression:
- schemaBasedQualifierWithRootEntity:

Initializing an EOKeyValueQualifier
- initWithKey:operatorSelector:value:
Returning information about an EOKeyValueQualifier
- selector
- key
- value

Instance Methods

evaluateWithObject:

@protocol EOQualifierEvaluation

- (BOOL)evaluateWithObject:anObject

Returns YES if the object anObject satisfies the qualifier, NO otherwise. When an EOKeyValueQualifier object receives the evaluateWithObject: message, it evaluates object to determine if it meets the qualifier criteria. This method can raise one of several possible exceptions if an error occurs. If your application allows users to construct arbitrary qualifiers (such as through a user interface), you may want to put exception handlers around this method to properly respond to errors (for example, by displaying a panel saying that the user typed a poorly formed qualifier).

initWithKey:operatorSelector:value:

- initWithKey:(NSString *)key operatorSelector:(SEL)selector value:(id)value

Initializes the receiver to compare values for key to value using the operator selector selector. The possible values for selector are as follows:

EOQualifierOperatorEqual
EOQualifierOperatorNotEqual
EOQualifierOperatorLessThan
EOQualifierOperatorGreaterThan
EOQualifierOperatorLessThanOrEqualTo
EOQualifierOperatorGreaterThanOrEqualTo
EOQualifierOperatorLike
EOQualifierOperatorCaseInsensitiveLike

Enterprise Objects Framework supports SQL generation for these selectors only.

For example, the following excerpt creates an EOKeyValueQualifier qual that has the key "name", the operator selector EOQualifierOperatorEqual, and the value "Smith". Once constructed, the qualifier qual is used to filter an in-memory array.

NSArray *employees;    /* Assume this exists. */

EOQualifier *qual = [[EOKeyValueQualifier alloc] initWithKey:@"name"

        operatorSelector:EOQualifierOperatorEqual

        value:@"Smith"];

return [employees filteredArrayUsingQualifier:qual];

key

- (NSString *)key

Returns the receiver's key.

selector

- (SEL)selector

Returns the receiver's selector.

value

- (id)value

Returns the receiver's value.

Copyright © 1997, Apple Computer, Inc. All rights reserved.