WebObjects 5.4.2

com.webobjects.eocontrol
Interface EORelationshipManipulation

All Known Subinterfaces:
EOEnterpriseObject
All Known Implementing Classes:
EOCustomObject, EOGenericRecord

public interface EORelationshipManipulation

The EORelationshipManipulation interface builds on the basic EOKeyValueCoding interface to allow you to modify to-many relationship properties. EOCustomObject and EOGenericRecord provide default implementations of EORelationshipManipulation, which you rarely (if ever) need to override.

The primitive methods addObjectToPropertyWithKey and removeObjectFromPropertyWithKey add and remove single objects from to-many relationship arrays. The two other methods in the interface, addObjectToBothSidesOfRelationshipWithKey and removeObjectFromBothSidesOfRelationshipWithKey, are implemented in terms of the two primitives to handle reciprocal relationships. These methods find the inverse relationship to the one identified by the specified key (if there is such an inverse relationship) and use addObjectToPropertyWithKey and removeObjectFromPropertyWithKey to alter both relationships, whether they're to-one or to-many.

The primitive methods first check for a method you might implement, addToKey or removeFromKey, invoking that method if it's implemented, otherwise using the basic key-value coding methods to do the work. Consequently, you rarely need to provide your own implementations of EORelationshipManipulation. Rather, you can provide relationship accessors (addToKey or removeFromKey) whenever you need to implement custom business logic.


Method Summary
 void addObjectToBothSidesOfRelationshipWithKey(EORelationshipManipulation eo, String key)
           
 void addObjectToPropertyWithKey(Object eo, String key)
          Adds the enterprise object eo to the receiver's relationship value(s), without setting any inverse relationship.
 void removeObjectFromBothSidesOfRelationshipWithKey(EORelationshipManipulation eo, String key)
          Removes the enterprise object eo from the receiver's relationship, which is identified by key, and also removes the receiver from the enterprise object eo's inverse relationship if there is one.
 void removeObjectFromPropertyWithKey(Object eo, String key)
          Removes the enterprise object eo from the receiver's relationship value(s), without modifying any inverse relationship.
 

Method Detail

addObjectToPropertyWithKey

void addObjectToPropertyWithKey(Object eo,
                                String key)
Adds the enterprise object eo to the receiver's relationship value(s), without setting any inverse relationship. The relationship is identified by key. Similar to the implementation of takeValueForKey, EOCustomObject's implementation of this method first attempts to invoke a method of the form "addToKey" (with "Key" being the relationship's name). If the receiver doesn't have such a method, this method gets the property array or value using valueForKey and operates directly on that. For a to-many relationship, this method adds eo to the array if it is not already in the array. For a to-one relationship, this method replaces the previous value with eo.

Parameters:
eo - The enterprise object to be added or set to the relationship.
key - The name of the relationship.

removeObjectFromPropertyWithKey

void removeObjectFromPropertyWithKey(Object eo,
                                     String key)
Removes the enterprise object eo from the receiver's relationship value(s), without modifying any inverse relationship. The relationship is identified by key. Similar to the implementation of takeValueForKey, EOCustomObject's implementation of this method first attempts to invoke a method of the form "removeFromKey" (with "Key" being the relationship's name). If the receiver doesn't have such a method, this method gets the property array or value using valueForKey and operates directly on that. For a to-many relationship, this method removes eo from the array. For a to-one relationship, this method replaces eo with null.

Parameters:
eo - The enterprise object to be removed from the relationship.
key - The name of the relationship.

addObjectToBothSidesOfRelationshipWithKey

void addObjectToBothSidesOfRelationshipWithKey(EORelationshipManipulation eo,
                                               String key)

removeObjectFromBothSidesOfRelationshipWithKey

void removeObjectFromBothSidesOfRelationshipWithKey(EORelationshipManipulation eo,
                                                    String key)
Removes the enterprise object eo from the receiver's relationship, which is identified by key, and also removes the receiver from the enterprise object eo's inverse relationship if there is one. For a to-one relationship, anObject is removed using takeValueForKey with null as the value. For a to-many relationship, anObject is removed using removeObjectFromPropertyWithKey.

Parameters:
eo - The enterprise object to be removed from the relationship.
key - The name of the relationship.

Last updated June 2008

Copyright © 2000-2008 Apple Inc.