PATH Documentation > WebObjects

Table of Contents

EOKeyComparisonQualifier


Inherits from:
EOQualifier
Implements:
EOQualifierEvaluation
NSCoding
EOKeyValueArchiving
Package:
com.webobjects.eocontrol


Class Description


EOKeyComparisonQualifier is a subclass of EOQualifier that compares a named property of an object with a named value of another object. For example, to return all of the employees whose salaries are greater than those of their managers, you might use an expression such as "salary > manager.salary", where "salary" is the left key and "manager.salary" is the right key. The "left key" is the property of the first object that's being compared to a property in a second object; the property in the second object is the "right key." Both the left key and the right key might be key paths. You can use EOKeyComparisonQualifier to compare properties of two different objects or to compare two properties of the same object.

EOKeyComparisonQualifier implements the EOQualifierEvaluation interface, which defines the method evaluateWithObject for in-memory evaluation. When an EOKeyComparisonQualifier 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, EOKeyComparisonQualifier 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).




Interfaces Implemented


EOQualifierEvaluation
evaluateWithObject
NSCoding
classForCoder
decodeObject
encodeWithCoder
EOKeyValueArchiving
decodeWithKeyValueUnarchiver
encodeWithKeyValueArchiver


Constructors



EOKeyComparisonQualifier

public EOKeyComparisonQualifier( String leftKey, NSSelector selector, String rightKey)

Creates and returns a new EOKeyComparisonQualifier object that compares the properties named by leftKey and rightKey, using the operator method selector, one of:

Enterprise Objects Framework supports SQL generation for these methods only. You can generate SQL using the EOSQLExpression static method sqlStringForKeyComparisonQualifier.

For example, the following excerpt creates an EOKeyComparisonQualifier qual that has the left key "lastName", the operator method EOQualifierOperatorEqual, and the right key "member.lastName". Once constructed, the qualifier qual is used to filter an in-memory array. The code excerpt returns an array of Guest objects whose lastName properties have the same value as the lastName property of the guest's sponsoring member (this example is based on the Rentals sample database).


NSArray guests; /* Assume this exists */
EOKeyComparisonQualifier qual = new EOKeyComparisonQualifier("lastName", 
    EOQualifier.QualifierOperatorEqual, 
    "member.lastName");

return EOQualifier.filteredArrayWithQualifier(guests, qual);




Static Methods



decodeObject

public static Object decodeObject(NSCoder coder)

Conformance to NSCoding.

decodeWithKeyValueUnarchiver

public static Object decodeWithKeyValueUnarchiver(EOKeyValueUnarchiver unarchiver)

Conformance to EOKeyValueArchiving.


Instance Methods



addQualifierKeysToSet

public void addQualifierKeysToSet(NSMutableSet aSet)

Description forthcoming.

classForCoder

public Class classForCoder()

Conformance to NSCoding.

encodeWithCoder

public void encodeWithCoder(NSCoder coder)

Conformance to NSCoding.

encodeWithKeyValueArchiver

public void encodeWithKeyValueArchiver(EOKeyValueArchiver archiver)

Conformance to EOKeyValueArchiving.

evaluateWithObject

public boolean evaluateWithObject(NSKeyValueCodingAdditions object)

Returns true if the object object satisfies the qualifier, false otherwise. When an EOKeyComparisonQualifier object receives an evaluateWithObject message, it evaluates object to determine if it meets the qualifier criteria. This method can throw 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 write code to catch any exceptions and properly respond to errors (for example, by displaying a panel saying that the user typed a poorly formed qualifier).

leftKey

public String leftKey()

Returns the receiver's left key.

qualifierWithBindings

public EOQualifier qualifierWithBindings( NSDictionary, boolean)

Description forthcoming.

rightKey

public String rightKey()

Returns the receiver's right key.

selector

public NSSelector selector()

Returns the receiver's selector.

toString

public String toString()

Description forthcoming.

validateKeysWithRootClassDescription

public void validateKeysWithRootClassDescription(EOClassDescription classDesc)

Ensures that the receiver contains keys and key paths that belong to or originate from classDesc. This method raises an exception if an unknown key is found, otherwise it returns null to indicate that the keys contained by the qualifier are valid.

© 2001 Apple Computer, Inc. (Last Published April 19, 2001)


Table of Contents