net.wotonomy.control
Class EOCustomObject

java.lang.Object
  extended by net.wotonomy.control.EOCustomObject
All Implemented Interfaces:
EODeferredFaulting, EOEnterpriseObject, EOFaulting, EOKeyValueCoding, EOKeyValueCodingAdditions, EORelationshipManipulation, EOValidation, net.wotonomy.foundation.NSKeyValueCoding, net.wotonomy.foundation.NSKeyValueCodingAdditions
Direct Known Subclasses:
EOGenericRecord

public class EOCustomObject
extends java.lang.Object
implements EOEnterpriseObject, EOKeyValueCodingAdditions, EODeferredFaulting, EORelationshipManipulation, EOValidation

EOCustomObject implements all the necessary interfaces to receive first-class treatment from the control framework. The implementation delegates as much class meta-behavior as possible to EOClassDescription, letting subclasses focus exclusively on business logic while still allowing them to customize as much class behavior as needed.

Version:
$Revision: 894 $
Author:
michael@mpowers.net, $Author: cgruber $

Nested Class Summary
 
Nested classes/interfaces inherited from interface net.wotonomy.control.EOKeyValueCodingAdditions
EOKeyValueCodingAdditions.DefaultImplementation, EOKeyValueCodingAdditions.Utility
 
Nested classes/interfaces inherited from interface net.wotonomy.foundation.NSKeyValueCoding
net.wotonomy.foundation.NSKeyValueCoding.Null
 
Nested classes/interfaces inherited from interface net.wotonomy.foundation.NSKeyValueCoding
net.wotonomy.foundation.NSKeyValueCoding.Null
 
Field Summary
 
Fields inherited from interface net.wotonomy.foundation.NSKeyValueCoding
NullValue
 
Fields inherited from interface net.wotonomy.foundation.NSKeyValueCoding
NullValue
 
Constructor Summary
EOCustomObject()
          Default constructor initializes private state.
EOCustomObject(EOEditingContext aContext, EOClassDescription aClassDescription, EOGlobalID aGlobalID)
          Preferred constructor, specifying an editing context, a class description, and a global id, any or all of which may be null.
 
Method Summary
 void addObjectToBothSidesOfRelationshipWithKey(EORelationshipManipulation anObject, java.lang.String aKey)
          As addObjectToProperty with key, but also performs the reciprocal operation on the other side of the relationship.
 void addObjectToPropertyWithKey(java.lang.Object anObject, java.lang.String aKey)
          Adds the specified object to the relationship on this object specified by the key.
 net.wotonomy.foundation.NSArray allPropertyKeys()
          Returns a List of all property keys defined on this object.
 net.wotonomy.foundation.NSArray attributeKeys()
          Returns a list of all attributes defined on this object.
 void awakeFromFetch(EOEditingContext anEditingContext)
          Called when the object has first been fetched into the specified editing context.
 void awakeFromInsertion(EOEditingContext anEditingContext)
          Called when the object has been inserted into the specified editing context.
static boolean canAccessFieldsDirectly()
          Specifies whether the implementation of EOKeyValueCoding is permitted to access field directly.
 net.wotonomy.foundation.NSDictionary changesFromSnapshot(net.wotonomy.foundation.NSDictionary snapshot)
          Returns a Map representing the delta of the current state from the state represented in the specified snapshot.
 EOClassDescription classDescription()
          Returns a class description for this object.
 EOClassDescription classDescriptionForDestinationKey(java.lang.String aKey)
          Returns a class description for the object at the other end of the specified relationship key.
 void clearFault()
          Called by EOFaultHandler to prepare the object to be turned into a fault.
 void clearProperties()
          Clears all property values for this object.
 int deleteRuleForRelationshipKey(java.lang.String aRelationshipKey)
          Returns the delete rule constant defined on EOClassDescription for the relationship defined by the specified key.
 EOEditingContext editingContext()
          Returns the editing context in which this object is registered.
 java.lang.String entityName()
          Returns the name of the entity that this object represents.
 java.lang.String eoDescription()
          Returns a String containing all property keys and values for this object.
 java.lang.String eoShallowDescription()
          Returns a String containing all attribute keys and values for this object.
 EOFaultHandler faultHandler()
          Returns this object's EOFaultHandler.
 java.lang.Object handleQueryWithUnboundKey(java.lang.String aKey)
          Called by valueForKey when the specified key is not found on this object.
 void handleTakeValueForUnboundKey(java.lang.Object aValue, java.lang.String aKey)
          Called by takeValueForKey when the specified key is not found on this object.
 java.lang.String inverseForRelationshipKey(java.lang.String aRelationshipKey)
          Returns the key used to reference this object on the object at the other end of the specified relationship.
 boolean isFault()
          Returns whether this object is currently a fault.
 boolean isToManyKey(java.lang.String aKey)
          Returns whether the specified relationship key represents a to-many relationship.
 boolean ownsDestinationObjectsForRelationshipKey(java.lang.String aKey)
          Returns whether the objects at the other end of the specified relationship should be deleted when this object is deleted.
 void propagateDeleteWithEditingContext(EOEditingContext aContext)
          Called to perform the delete propagation for this object on the specified editing context.
 void reapplyChangesFromDictionary(net.wotonomy.foundation.NSDictionary aDeltaSnapshot)
          Applies the changes from the specified snapshot to this object.
 void removeObjectFromBothSidesOfRelationshipWithKey(EORelationshipManipulation anObject, java.lang.String aKey)
          As removeObjectFromPropertyWithKey with key, but also performs the reciprocal operation on the other side of the relationship.
 void removeObjectFromPropertyWithKey(java.lang.Object anObject, java.lang.String aKey)
          Removes the specified object from the relationship on this object specified by the key.
static boolean shouldUseStoredAccessors()
          Specifies whether the implementation of EOKeyValueCoding is permitted to access private accessors.
 net.wotonomy.foundation.NSDictionary snapshot()
          Returns a snapshot of the current state of this object.
 java.lang.Object storedValueForKey(java.lang.String aKey)
          Returns the value for the private field that corresponds to the specified property.
 void takeStoredValueForKey(java.lang.Object aValue, java.lang.String aKey)
          Sets the the private field that corresponds to the specified property to the specified value.
 void takeValueForKey(java.lang.Object aValue, java.lang.String aKey)
          Sets the property to the specified value.
 void takeValueForKeyPath(java.lang.Object aValue, java.lang.String aKeyPath)
          Sets the value for the specified key path, which is a series of keys delimited by ".", for example: "createTime.year.length".
 void takeValuesFromDictionary(java.util.Map aMap)
          Takes the keys from the specified map as properties and applies the corresponding values, each of which might be set by calling takeValueForKey.
 net.wotonomy.foundation.NSArray toManyRelationshipKeys()
          Returns a List of the to-many relationship keys for this object.
 net.wotonomy.foundation.NSArray toOneRelationshipKeys()
          Returns a List of the to-one relationship keys for this object.
 void turnIntoFault(EOFaultHandler aFaultHandler)
          Turns this object into a fault using the specified fault handler.
 void unableToSetNullForKey(java.lang.String aKey)
          Called by takeValueForKey when the type of the specified key is not allowed to be null, as is the case with primitive types.
 void updateFromSnapshot(net.wotonomy.foundation.NSDictionary aSnapshot)
          Applies the specified snapshot to this object, converting NSNulls to null and calling takeStoredValueForKey for each key in the Map.
 java.lang.String userPresentableDescription()
          Returns a short, stateful string representation of this object.
static boolean usesDeferredFaultCreation()
          Specifies whether deferred faults should be used.
 void validateForDelete()
          Validates this object for delete.
 void validateForInsert()
          Validates this object for insertion into the external store.
 void validateForSave()
          Validates this object for a commit to the external store.
 void validateForUpdate()
          Validates this object for update to the external store.
 java.lang.Object valueForKey(java.lang.String aKey)
          Returns the value for the specified property.
 java.lang.Object valueForKeyPath(java.lang.String aKeyPath)
          Returns the value for the specified key path, which is a series of keys delimited by ".", for example: "createTime.year.length".
 net.wotonomy.foundation.NSDictionary valuesForKeys(java.util.List aKeyList)
          Returns a Map of the specified keys to their values, each of which might be obtained by calling valueForKey.
 void willChange()
          This method should be called by each setter method on this object before changes are made to the object's internal state.
 void willRead()
          Called to completely fire the fault, reading all attributes.
 void willRead(java.lang.String aKey)
          Called to fire the fault for the specified key.
 java.lang.Object willReadRelationship(java.lang.Object anObject)
          Returns a fault for the specified deferred fault.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EOCustomObject

public EOCustomObject()
Default constructor initializes private state. EditingContext and ClassDescription are set to null.


EOCustomObject

public EOCustomObject(EOEditingContext aContext,
                      EOClassDescription aClassDescription,
                      EOGlobalID aGlobalID)
Preferred constructor, specifying an editing context, a class description, and a global id, any or all of which may be null. Subclasses should invoke this constructor.

Method Detail

canAccessFieldsDirectly

public static boolean canAccessFieldsDirectly()
Specifies whether the implementation of EOKeyValueCoding is permitted to access field directly. This implementation returns true; subclasses may override to customize this behavior.


shouldUseStoredAccessors

public static boolean shouldUseStoredAccessors()
Specifies whether the implementation of EOKeyValueCoding is permitted to access private accessors. This implementation returns true; subclasses may override to customize this behavior.


usesDeferredFaultCreation

public static boolean usesDeferredFaultCreation()
Specifies whether deferred faults should be used. This implementation returns false; subclasses may override to customize this behavior.


allPropertyKeys

public net.wotonomy.foundation.NSArray allPropertyKeys()
Returns a List of all property keys defined on this object. This includes both attributes and relationships. This implementation returns the union of attributeKeys, toOneRelationshipKeys, and toManyRelationshipKeys.

Specified by:
allPropertyKeys in interface EOEnterpriseObject

attributeKeys

public net.wotonomy.foundation.NSArray attributeKeys()
Returns a list of all attributes defined on this object. Attributes are all properties that are not relationships. This implementation retrieves the keys from the class description.

Specified by:
attributeKeys in interface EOEnterpriseObject

awakeFromFetch

public void awakeFromFetch(EOEditingContext anEditingContext)
Called when the object has first been fetched into the specified editing context. This implementation calls awakeObjectFromFetch on the class description.

Specified by:
awakeFromFetch in interface EOEnterpriseObject

awakeFromInsertion

public void awakeFromInsertion(EOEditingContext anEditingContext)
Called when the object has been inserted into the specified editing context. This implementation calls awakeObjectFromInsertion on the class description.

Specified by:
awakeFromInsertion in interface EOEnterpriseObject

changesFromSnapshot

public net.wotonomy.foundation.NSDictionary changesFromSnapshot(net.wotonomy.foundation.NSDictionary snapshot)
Returns a Map representing the delta of the current state from the state represented in the specified snapshot. The result will contain only the keys that have changed and their values. Relationship keys will map to an NSArray that contains an NSArray of added objects and an NSArray of removed objects, in that order.

Specified by:
changesFromSnapshot in interface EOEnterpriseObject

classDescription

public EOClassDescription classDescription()
Returns a class description for this object. Calls EOClassDescription.classDescriptionForClass.

Specified by:
classDescription in interface EOEnterpriseObject

classDescriptionForDestinationKey

public EOClassDescription classDescriptionForDestinationKey(java.lang.String aKey)
Returns a class description for the object at the other end of the specified relationship key. This implementation calls to the classDescription.

Specified by:
classDescriptionForDestinationKey in interface EOEnterpriseObject

clearProperties

public void clearProperties()
Clears all property values for this object. This method is called to clean-up an object that will no longer be used, and implementations should ensure that all references are set to null to prevent problems with garbage-collection.

Specified by:
clearProperties in interface EOEnterpriseObject

deleteRuleForRelationshipKey

public int deleteRuleForRelationshipKey(java.lang.String aRelationshipKey)
Returns the delete rule constant defined on EOClassDescription for the relationship defined by the specified key. This implementation calls to the classDescription.

Specified by:
deleteRuleForRelationshipKey in interface EOEnterpriseObject

editingContext

public EOEditingContext editingContext()
Returns the editing context in which this object is registered.

Specified by:
editingContext in interface EOEnterpriseObject

entityName

public java.lang.String entityName()
Returns the name of the entity that this object represents.

Specified by:
entityName in interface EOEnterpriseObject

eoDescription

public java.lang.String eoDescription()
Returns a String containing all property keys and values for this object. Relationships should be represented by calling eoShallowDescription() on the object.

Specified by:
eoDescription in interface EOEnterpriseObject

eoShallowDescription

public java.lang.String eoShallowDescription()
Returns a String containing all attribute keys and values for this object. Relationships are not included.

Specified by:
eoShallowDescription in interface EOEnterpriseObject

inverseForRelationshipKey

public java.lang.String inverseForRelationshipKey(java.lang.String aRelationshipKey)
Returns the key used to reference this object on the object at the other end of the specified relationship. This implementation calls to the class description.

Specified by:
inverseForRelationshipKey in interface EOEnterpriseObject

isToManyKey

public boolean isToManyKey(java.lang.String aKey)
Returns whether the specified relationship key represents a to-many relationship.

Specified by:
isToManyKey in interface EOEnterpriseObject

ownsDestinationObjectsForRelationshipKey

public boolean ownsDestinationObjectsForRelationshipKey(java.lang.String aKey)
Returns whether the objects at the other end of the specified relationship should be deleted when this object is deleted. This implementation calls to the class description.

Specified by:
ownsDestinationObjectsForRelationshipKey in interface EOEnterpriseObject

propagateDeleteWithEditingContext

public void propagateDeleteWithEditingContext(EOEditingContext aContext)
Called to perform the delete propagation for this object on the specified editing context. All relationships should be processed according to their corresponding delete rule. This implementation calls to the class description.

Specified by:
propagateDeleteWithEditingContext in interface EOEnterpriseObject

reapplyChangesFromDictionary

public void reapplyChangesFromDictionary(net.wotonomy.foundation.NSDictionary aDeltaSnapshot)
Applies the changes from the specified snapshot to this object.

Specified by:
reapplyChangesFromDictionary in interface EOEnterpriseObject
See Also:
changesFromSnapshot(NSDictionary)

snapshot

public net.wotonomy.foundation.NSDictionary snapshot()
Returns a snapshot of the current state of this object. All property keys are mapped to their values; nulls are represented by NSNull.

Specified by:
snapshot in interface EOEnterpriseObject

toManyRelationshipKeys

public net.wotonomy.foundation.NSArray toManyRelationshipKeys()
Returns a List of the to-many relationship keys for this object. This implementation calls to the class description.

Specified by:
toManyRelationshipKeys in interface EOEnterpriseObject

toOneRelationshipKeys

public net.wotonomy.foundation.NSArray toOneRelationshipKeys()
Returns a List of the to-one relationship keys for this object. This implementation calls to the class description.

Specified by:
toOneRelationshipKeys in interface EOEnterpriseObject

updateFromSnapshot

public void updateFromSnapshot(net.wotonomy.foundation.NSDictionary aSnapshot)
Applies the specified snapshot to this object, converting NSNulls to null and calling takeStoredValueForKey for each key in the Map.

Specified by:
updateFromSnapshot in interface EOEnterpriseObject

userPresentableDescription

public java.lang.String userPresentableDescription()
Returns a short, stateful string representation of this object. This implementation calls to the class description.

Specified by:
userPresentableDescription in interface EOEnterpriseObject

willChange

public void willChange()
This method should be called by each setter method on this object before changes are made to the object's internal state. This implementation calls EOObserverCenter.notifyObserversObjectWillChange( this ),

Specified by:
willChange in interface EOEnterpriseObject

valueForKey

public java.lang.Object valueForKey(java.lang.String aKey)
Returns the value for the specified property. If the property does not exist, this method should call handleQueryWithUnboundKey.

Specified by:
valueForKey in interface EOKeyValueCoding
Specified by:
valueForKey in interface net.wotonomy.foundation.NSKeyValueCoding

takeValueForKey

public void takeValueForKey(java.lang.Object aValue,
                            java.lang.String aKey)
Sets the property to the specified value. If the property does not exist, this method should call handleTakeValueForUnboundKey. If the property is of a type that cannot allow null (e.g. primitive types) and aValue is null, this method should call unableToSetNullForKey.

Specified by:
takeValueForKey in interface EOKeyValueCoding
Specified by:
takeValueForKey in interface net.wotonomy.foundation.NSKeyValueCoding

storedValueForKey

public java.lang.Object storedValueForKey(java.lang.String aKey)
Returns the value for the private field that corresponds to the specified property.

Specified by:
storedValueForKey in interface EOKeyValueCoding
Specified by:
storedValueForKey in interface net.wotonomy.foundation.NSKeyValueCoding

takeStoredValueForKey

public void takeStoredValueForKey(java.lang.Object aValue,
                                  java.lang.String aKey)
Sets the the private field that corresponds to the specified property to the specified value.

Specified by:
takeStoredValueForKey in interface EOKeyValueCoding
Specified by:
takeStoredValueForKey in interface net.wotonomy.foundation.NSKeyValueCoding

handleQueryWithUnboundKey

public java.lang.Object handleQueryWithUnboundKey(java.lang.String aKey)
Called by valueForKey when the specified key is not found on this object. Implementing classes should handle the specified value or otherwise throw an exception.

Specified by:
handleQueryWithUnboundKey in interface EOKeyValueCoding
Specified by:
handleQueryWithUnboundKey in interface net.wotonomy.foundation.NSKeyValueCoding

handleTakeValueForUnboundKey

public void handleTakeValueForUnboundKey(java.lang.Object aValue,
                                         java.lang.String aKey)
Called by takeValueForKey when the specified key is not found on this object. Implementing classes should handle the specified value or otherwise throw an exception.

Specified by:
handleTakeValueForUnboundKey in interface EOKeyValueCoding
Specified by:
handleTakeValueForUnboundKey in interface net.wotonomy.foundation.NSKeyValueCoding

unableToSetNullForKey

public void unableToSetNullForKey(java.lang.String aKey)
Called by takeValueForKey when the type of the specified key is not allowed to be null, as is the case with primitive types. Implementing classes should handle this case appropriately or otherwise throw an exception.

Specified by:
unableToSetNullForKey in interface EOKeyValueCoding
Specified by:
unableToSetNullForKey in interface net.wotonomy.foundation.NSKeyValueCoding

valueForKeyPath

public java.lang.Object valueForKeyPath(java.lang.String aKeyPath)
Returns the value for the specified key path, which is a series of keys delimited by ".", for example: "createTime.year.length".

Specified by:
valueForKeyPath in interface net.wotonomy.foundation.NSKeyValueCodingAdditions

takeValueForKeyPath

public void takeValueForKeyPath(java.lang.Object aValue,
                                java.lang.String aKeyPath)
Sets the value for the specified key path, which is a series of keys delimited by ".", for example: "createTime.year.length". The value is set for the last object referenced by the key path.

Specified by:
takeValueForKeyPath in interface net.wotonomy.foundation.NSKeyValueCodingAdditions

valuesForKeys

public net.wotonomy.foundation.NSDictionary valuesForKeys(java.util.List aKeyList)
Returns a Map of the specified keys to their values, each of which might be obtained by calling valueForKey.

Specified by:
valuesForKeys in interface net.wotonomy.foundation.NSKeyValueCodingAdditions

takeValuesFromDictionary

public void takeValuesFromDictionary(java.util.Map aMap)
Takes the keys from the specified map as properties and applies the corresponding values, each of which might be set by calling takeValueForKey.

Specified by:
takeValuesFromDictionary in interface net.wotonomy.foundation.NSKeyValueCodingAdditions

clearFault

public void clearFault()
Called by EOFaultHandler to prepare the object to be turned into a fault.

Specified by:
clearFault in interface EOFaulting

faultHandler

public EOFaultHandler faultHandler()
Returns this object's EOFaultHandler.

Specified by:
faultHandler in interface EOFaulting

isFault

public boolean isFault()
Returns whether this object is currently a fault. Returns true if this object has not yet retrieved any values.

Specified by:
isFault in interface EOFaulting

turnIntoFault

public void turnIntoFault(EOFaultHandler aFaultHandler)
Turns this object into a fault using the specified fault handler.

Specified by:
turnIntoFault in interface EOFaulting

willRead

public void willRead()
Called to completely fire the fault, reading all attributes. This method may be implemented to call willRead(null).

Specified by:
willRead in interface EOFaulting

willRead

public void willRead(java.lang.String aKey)
Called to fire the fault for the specified key. The fault manager is required to populate the specified key with a value, and may populate any or all of the other values on this object. A null key will populate all values on the object. NOTE: This method is not part of the specification.

Specified by:
willRead in interface EOFaulting

willReadRelationship

public java.lang.Object willReadRelationship(java.lang.Object anObject)
Returns a fault for the specified deferred fault.

Specified by:
willReadRelationship in interface EODeferredFaulting

addObjectToPropertyWithKey

public void addObjectToPropertyWithKey(java.lang.Object anObject,
                                       java.lang.String aKey)
Adds the specified object to the relationship on this object specified by the key. For to-one relationships, this operation is the same as valueForKey.

Specified by:
addObjectToPropertyWithKey in interface EORelationshipManipulation

removeObjectFromPropertyWithKey

public void removeObjectFromPropertyWithKey(java.lang.Object anObject,
                                            java.lang.String aKey)
Removes the specified object from the relationship on this object specified by the key. For to-one relationships, this operation is the same as takeValueForKey with a null value.

Specified by:
removeObjectFromPropertyWithKey in interface EORelationshipManipulation

addObjectToBothSidesOfRelationshipWithKey

public void addObjectToBothSidesOfRelationshipWithKey(EORelationshipManipulation anObject,
                                                      java.lang.String aKey)
As addObjectToProperty with key, but also performs the reciprocal operation on the other side of the relationship.

Specified by:
addObjectToBothSidesOfRelationshipWithKey in interface EORelationshipManipulation

removeObjectFromBothSidesOfRelationshipWithKey

public void removeObjectFromBothSidesOfRelationshipWithKey(EORelationshipManipulation anObject,
                                                           java.lang.String aKey)
As removeObjectFromPropertyWithKey with key, but also performs the reciprocal operation on the other side of the relationship.

Specified by:
removeObjectFromBothSidesOfRelationshipWithKey in interface EORelationshipManipulation

validateForDelete

public void validateForDelete()
Validates this object for delete. Throws an exception if this object cannot be deleted. This implementation calls to the class description.

Specified by:
validateForDelete in interface EOValidation

validateForInsert

public void validateForInsert()
Validates this object for insertion into the external store. Throws an exception if this object cannot be inserted. Validations here should be specific to insertion. This implementation calls validateForSave().

Specified by:
validateForInsert in interface EOValidation

validateForSave

public void validateForSave()
Validates this object for a commit to the external store. Throws an exception if this object cannot be committed. Validations here are not specific to either inserts or updates. This implementation calls to the class description.

Specified by:
validateForSave in interface EOValidation

validateForUpdate

public void validateForUpdate()
Validates this object for update to the external store. Throws an exception if this object cannot be updated. Validations here should be specific to updates. This implementation calls validateForSave().

Specified by:
validateForUpdate in interface EOValidation


Copyright © 2006 null. All Rights Reserved.