WebObjects 5.2.3

com.webobjects.eocontrol
Class EODetailDataSource

java.lang.Object
  extended bycom.webobjects.eocontrol.EODataSource
      extended bycom.webobjects.eocontrol.EODetailDataSource
All Implemented Interfaces:
EOKeyValueArchiving, Serializable

public class EODetailDataSource
extends EODataSource
implements Serializable, EOKeyValueArchiving

EODetailDataSource defines a data source for use in master-detail configurations, where operations in the detail data source are applied directly to properties of a master object. EODetailDataSource implements the standard fetchObjects, insertObject, and deleteObject methods to operate on a relationship property of its master object. It works for any concrete subclass of EODataSource, including another EODetailDataSource in a chain of master and detail data sources.

To set up an EODetailDataSource programmatically, you can typically create it by sending a dataSourceQualifiedByKey message to the master data source, then establish the master object with a qualifyWithRelationshipKey message. The latter method records the name of a relationship for a particular object to resolve in fetchObjects and to modify in insertObject and deleteObject. These three methods then manipulate the relationship property of the master object to perform the operations requested.

See Also:
fetchObjects(), insertObject(Object anObject), deleteObject(Object anObject), qualifyWithRelationshipKey(String relationshipKey, Object masterObject), Serialized Form

Nested Class Summary
 
Nested classes inherited from class com.webobjects.eocontrol.EOKeyValueArchiving
EOKeyValueArchiving.Awaking, EOKeyValueArchiving.FinishInitialization, EOKeyValueArchiving.Support
 
Constructor Summary
EODetailDataSource(EOClassDescription masterClassDescription, String key)
          Creates and returns a new EODetailDataSource object.
EODetailDataSource(EODataSource masterDataSource, String key)
          Creates and returns a new EODetailDataSource object.
 
Method Summary
 EOClassDescription classDescriptionForObjects()
          Returns the class description for the detail object if a detail key is defined, otherwise returns the master class description
 EODataSource dataSourceQualifiedByKey(String key)
          Creates an EODetailDataSource for key.
static Object decodeWithKeyValueUnarchiver(EOKeyValueUnarchiver unarchiver)
          Provides conformance to EOKeyValueArchiving.
 void deleteObject(Object eo)
          Sends a removeObjectFromBothSidesOfRelationshipWithKey message to the master object using detailKey.
 String detailKey()
          Gets the detail key of the receiver, which names the relationship for which the receiver provides objects to its master object.
 EOEditingContext editingContext()
          Returns the editing context of the master data source, or null if there is not one
 void encodeWithKeyValueArchiver(EOKeyValueArchiver archiver)
          Provides conformance to EOKeyValueArchiving.
 NSArray fetchObjects()
          Sends valueForKey (defined in the NSKeyValueCoding interface) to the master object with the receiver's detail key as the argument, constructs an array for the returned object or objects, and returns it.
 void insertObject(Object eo)
          Sends an addObjectToBothSidesOfRelationshipWithKey message to the master object.
 EOClassDescription masterClassDescription()
          Gets the EOClassDescription for the receiver's master object.
 EODataSource masterDataSource()
          Gets the master data source for the receiver.
 Object masterObject()
          Returns the master object of the receiver.
 void qualifyWithRelationshipKey(String key, Object sourceObject)
          Configures the receiver to provide objects based on the relationship of sourceObject named by key.
 void setDetailKey(String detailKeyPath)
          Sets the detail key of the receiver, which names the relationship for which the receiver provides objects to its master object.
 void setMasterClassDescription(EOClassDescription master)
          Assigns master as the EOClassDescription for the receiver's master object.
 
Methods inherited from class com.webobjects.eocontrol.EODataSource
createObject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EODetailDataSource

public EODetailDataSource(EOClassDescription masterClassDescription,
                          String key)
Creates and returns a new EODetailDataSource object. The new data source's masterObject is associated with masterClassDescription, and key is assigned to the new data source's detailKey. The constructor invokes qualifyWithRelationshipKey specifying key as the relationship key and null as the object.

Parameters:
masterClassDescription - class description for the master object
key - keypath defining relationship on the master object
See Also:
masterObject(), detailKey(), qualifyWithRelationshipKey( String relationshipKey , Object masterObject), masterClassDescription()

EODetailDataSource

public EODetailDataSource(EODataSource masterDataSource,
                          String key)
Creates and returns a new EODetailDataSource object. The new data source provides destination objects for the relationship named by a key from a masterObject in masterDataSource.

Parameters:
masterDataSource - provider of the master objects
key - the String giving the new relationship
See Also:
masterDataSource()
Method Detail

classDescriptionForObjects

public EOClassDescription classDescriptionForObjects()
Returns the class description for the detail object if a detail key is defined, otherwise returns the master class description

Overrides:
classDescriptionForObjects in class EODataSource
Returns:
EOClassDescription for the type of objects managed by the data source

dataSourceQualifiedByKey

public EODataSource dataSourceQualifiedByKey(String key)
Creates an EODetailDataSource for key.

Specified by:
dataSourceQualifiedByKey in class EODataSource
Parameters:
key - relationship key that is the destination object of the relationship
Returns:
detailed EODataSource that provides the destination objects of the relationship
See Also:
EODataSource.qualifyWithRelationshipKey(String key, Object sourceObject)

decodeWithKeyValueUnarchiver

public static Object decodeWithKeyValueUnarchiver(EOKeyValueUnarchiver unarchiver)
Provides conformance to EOKeyValueArchiving.

Parameters:
unarchiver -
Returns:
decoded object from the archive

deleteObject

public void deleteObject(Object eo)
Sends a removeObjectFromBothSidesOfRelationshipWithKey message to the master object using detailKey. Throws an IllegalStateException if there is no master object or no detail key set.

Specified by:
deleteObject in class EODataSource
Parameters:
eo - object to be deleted
Throws:
exception - if there's no master object or no detail key set

detailKey

public String detailKey()
Gets the detail key of the receiver, which names the relationship for which the receiver provides objects to its master object.

Returns:
name of the relationship for which the receiver provides objects; null if it has not been set yet
See Also:
qualifyWithRelationshipKey(String relationshipKey, Object masterObject)

editingContext

public EOEditingContext editingContext()
Returns the editing context of the master data source, or null if there is not one

Overrides:
editingContext in class EODataSource
Returns:
the EOEditingContext of the master object or its data source

encodeWithKeyValueArchiver

public void encodeWithKeyValueArchiver(EOKeyValueArchiver archiver)
Provides conformance to EOKeyValueArchiving.

Specified by:
encodeWithKeyValueArchiver in interface EOKeyValueArchiving
Parameters:
archiver -
See Also:
EOKeyValueArchiver

fetchObjects

public NSArray fetchObjects()
Sends valueForKey (defined in the NSKeyValueCoding interface) to the master object with the receiver's detail key as the argument, constructs an array for the returned object or objects, and returns it. Returns an empty array if there's no master object, or returns an array containing the master object itself if no detail key is set.

Overrides:
fetchObjects in class EODataSource
Returns:
an immutable array containing objects in the detail relationship, the master object if no relationship is defined, or the empty array

insertObject

public void insertObject(Object eo)
Sends an addObjectToBothSidesOfRelationshipWithKey message to the master object.

Specified by:
insertObject in class EODataSource
Parameters:
eo - object to be inserted
Throws:
exception - if there's no master object or no detail keyset

masterClassDescription

public EOClassDescription masterClassDescription()
Gets the EOClassDescription for the receiver's master object.

Returns:
EOClassDescription of the receiver's master object
See Also:
setMasterClassDescription(EOClassDescription master), EODetailDataSource(EOClassDescription masterClassDescription, String key)

masterDataSource

public EODataSource masterDataSource()
Gets the master data source for the receiver.

Returns:
receiver's master data source
See Also:
detailKey(), EODetailDataSource(EOClassDescription masterClassDescription, String key)

masterObject

public Object masterObject()
Returns the master object of the receiver.

Returns:
object in the master data source for which the receiver provides objects
See Also:
detailKey(), qualifyWithRelationshipKey( String relationshipKey, Object masterObject)

qualifyWithRelationshipKey

public void qualifyWithRelationshipKey(String key,
                                       Object sourceObject)
Configures the receiver to provide objects based on the relationship of sourceObject named by key. Relationship key can be different from the one provided to the constructor, which changes the relationship the receiver operates on. If sourceObject is null this method causes the receiver to return an empty array when sent a fetchObjects message.

Specified by:
qualifyWithRelationshipKey in class EODataSource
Parameters:
key - relationship key
sourceObject - the source object
See Also:
fetchObjects(), detailKey()

setDetailKey

public void setDetailKey(String detailKeyPath)
Sets the detail key of the receiver, which names the relationship for which the receiver provides objects to its master object.

Parameters:
detailKeyPath - used to qualify the master-detail relationship of the datasource

setMasterClassDescription

public void setMasterClassDescription(EOClassDescription master)
Assigns master as the EOClassDescription for the receiver's master object.

Parameters:
master - EOClassDescription for the receiver's master object
See Also:
masterClassDescription()

Last updated Thu Oct 21 15:04:16 PDT 2004.

Copyright © 2004 Apple Computer, Inc.