|
WebObjects 5.4.2 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.webobjects.eocontrol.EOCustomObject
public abstract class EOCustomObject
The EOCustomObject class provides a default implementation of the EOEnterpriseObject interface. If a custom Enterprise Object class needs to be created, you can subclass EOCustomObject and inherit the framework's default implementations. Some of the methods are for subclasses to implement or override, but most are meant to be used as defined by EOCustomObject.
EOCustomObject's constructors are not meant to be invoked; an instance of EOCustomObject would never be created. EOCustomObject provides them to demonstrate the constructors that custom enterprise objects should implement.
EOEnterpriseObject
,
Serialized FormNested Class Summary |
---|
Nested classes/interfaces inherited from interface com.webobjects.eocontrol.EOKeyValueCodingAdditions |
---|
EOKeyValueCodingAdditions.DefaultImplementation, EOKeyValueCodingAdditions.Utility |
Nested classes/interfaces inherited from interface com.webobjects.foundation.NSKeyValueCoding |
---|
NSKeyValueCoding.ErrorHandling, NSKeyValueCoding.MapImplementation, NSKeyValueCoding.Null, NSKeyValueCoding.UnknownKeyException, NSKeyValueCoding.ValueAccessor |
Nested classes/interfaces inherited from interface com.webobjects.foundation.NSKeyValueCoding |
---|
NSKeyValueCoding.ErrorHandling, NSKeyValueCoding.MapImplementation, NSKeyValueCoding.Null, NSKeyValueCoding.UnknownKeyException, NSKeyValueCoding.ValueAccessor |
Nested classes/interfaces inherited from interface com.webobjects.foundation.NSValidation |
---|
NSValidation.ValidationException |
Field Summary |
---|
Fields inherited from interface com.webobjects.foundation.NSKeyValueCodingAdditions |
---|
KeyPathSeparator |
Fields inherited from interface com.webobjects.foundation.NSKeyValueCoding |
---|
NullValue |
Fields inherited from interface com.webobjects.foundation.NSKeyValueCoding |
---|
NullValue |
Constructor Summary | |
---|---|
EOCustomObject()
Default constructor. |
|
EOCustomObject(EOEditingContext editingContext,
EOClassDescription classDescription,
EOGlobalID gid)
Deprecated. the default or 0 argument constructor should be used instead |
Method Summary | |
---|---|
void |
addObjectToBothSidesOfRelationshipWithKey(EORelationshipManipulation object,
String key)
Sets or adds object as the destination for the receiver's relationship identified by key , and also sets or adds the receiver for object 's reciprocal relationship if there is one. |
void |
addObjectToPropertyWithKey(Object eo,
String key)
Adds to the relationship named key the object eo without setting inverse relationships. |
NSArray |
allPropertyKeys()
Returns the union of the keys returned by attributeKeys , toOneRelationshipKeys , and toManyRelationshipKeys . |
NSArray |
attributeKeys()
Returns the names of the receiver's attributes (not relationship properties). |
void |
awakeFromClientUpdate(EOEditingContext ec)
Invoked on a server-side enterprise object after it has been updated with changes from a client application. |
void |
awakeFromFetch(EOEditingContext ec)
Overridden by subclasses to perform additional initialization on the receiver upon its being fetched from the external repository into ec . |
void |
awakeFromInsertion(EOEditingContext ec)
Overridden by subclasses to perform additional initialization on the receiver upon its being inserted into ec . |
static boolean |
canAccessFieldsDirectly()
Returns true. |
NSDictionary |
changesFromSnapshot(NSDictionary snapshot)
Returns a dictionary whose keys correspond to the receiver's properties with uncommitted changes relative to snapshot , and whose values are the uncommitted values. |
EOClassDescription |
classDescription()
Returns the EOClassDescription registered for the receiver's class by invoking the EOClassDescription static method classDescriptionForClass . |
EOClassDescription |
classDescriptionForDestinationKey(String detailKey)
Returns the EOClassDescription for the destination objects of the relationship identified by detailKey . |
void |
clearFault()
Sets the faultHandler to null . |
void |
clearProperties()
Sets all of the receiver's to-one and to-many relationships to null . |
int |
deleteRuleForRelationshipKey(String relationshipKey)
Returns a rule indicating how to handle the destination of the receiver's relationship named by relationshipKey when the receiver is deleted. |
EOEditingContext |
editingContext()
Returns the editing context that contains the receiver or null if none is set. |
String |
entityName()
Returns the name of the receiver's entity, or null if it doesn't have one by sending an entityName message to the receiver's EOClassDescription. |
String |
eoDescription()
Returns a full description of the receiver's property values by extracting them using the key-value coding methods. |
String |
eoShallowDescription()
Similar to eoDescription , but doesn't descend into relationships. |
boolean |
equals(Object other)
EOF requires all EOs define equality as (this == other) To compare EOs in different EOEditingContexts, consider instead comparing their EOGlobalIDs with equals() |
protected void |
excludeObjectFromPropertyWithKey(Object eo,
String key)
Removes the object eo from the to-many relationship named key without affecting inverse relationships, by directly modifying the property storing the to-many relationship. |
EOFaultHandler |
faultHandler()
Returns the receiver's fault handler. |
Object |
handleQueryWithUnboundKey(String key)
Invoked from valueForKey when it finds no property binding for key . |
void |
handleTakeValueForUnboundKey(Object value,
String key)
Invoked from takeValueForKey when it finds no property binding for key . |
int |
hashCode()
This method must adhere to the contract specified in java.lang.Object.hashCode |
protected void |
includeObjectIntoPropertyWithKey(Object eo,
String key)
Adds to the relationship named key the object eo without affecting inverse relationships, by directly modifying the property storing the to-many relationship. |
String |
inverseForRelationshipKey(String relationshipKey)
Returns the name of the relationship pointing back to the receiver's class or entity from that named by relationshipKey , or null if there isn't one. |
Object |
invokeRemoteMethod(String methodName,
Class[] argumentTypes,
Object[] arguments)
Invokes a method on the server-side equivalent of the enterprise object. |
boolean |
isFault()
Returns true if the object's values haven't yet been fetched from the database. |
boolean |
isReadOnly()
Returns true if the receiver can not be modified, false if it can. |
boolean |
isToManyKey(String key)
Returns true if the receiver has a to-many relationship identified by key , false otherwise. |
Object |
opaqueState()
This methods returns an opaque object which encapsulates state private to EOF. |
boolean |
ownsDestinationObjectsForRelationshipKey(String relationshipKey)
Returns true if the receiver has a relationship identified by key that owns its destination, and false otherwise. |
void |
prepareValuesForClient()
Invoked on a server-side enterprise object before the values of it are distributed to a client application. |
void |
propagateDeleteWithEditingContext(EOEditingContext ec)
Deletes the destination objects of the receiver's relationships according to the delete rule for each relationship. |
protected Object |
readResolve()
|
void |
reapplyChangesFromDictionary(NSDictionary changes)
Similar to takeValuesFromDictionary , but the changes dictionary can contain arrays for to-many relationships. |
void |
removeObjectFromBothSidesOfRelationshipWithKey(EORelationshipManipulation object,
String key)
Removes object from the receiver's relationship identified by key , and also removes the receiver from objects 's reciprocal relationship if there is one. |
void |
removeObjectFromPropertyWithKey(Object eo,
String key)
Removes the object eo from the to-many relationship named key without affecting inverse relationships. |
static boolean |
shouldUseStoredAccessors()
Returns true. |
NSDictionary |
snapshot()
Returns a dictionary whose keys are those of the receiver's attributes, to-one relationships, and to-many relationships, and whose values are the values of those properties, with EONullValue substituted for null . |
Object |
storedValueForKey(String key)
Returns the value for the property identified by key . |
void |
takeStoredValueForKey(Object value,
String key)
Sets the property identified by key to value . |
void |
takeValueForKey(Object value,
String key)
Sets the receiver's value for the property identified by key to value . |
void |
takeValueForKeyPath(Object value,
String keyPath)
Sets the receiver's property identified by keyPath to value . |
void |
takeValuesFromDictionary(NSDictionary dictionary)
Sets properties of the receiver with values from dictionary , using its keys to identify the properties. |
void |
takeValuesFromDictionaryWithMapping(NSDictionary dictionary,
NSDictionary mapping)
Sets properties of the receiver with values from dictionary , using its keys and mapping to identify the properties. |
NSArray |
toManyRelationshipKeys()
Returns the names of the receiver's to-many relationships. |
NSArray |
toOneRelationshipKeys()
Returns the names of the receiver's to-one relationships. |
String |
toString()
String representation of the object. |
void |
turnIntoFault(EOFaultHandler handler)
Converts the receiver into a fault, assigning handler as the object that stores its original state and later converts the fault back into a normal object (typically by fetching data from an external repository). |
void |
unableToSetNullForKey(String key)
Invoked from takeValueForKey when it's given a null value for a scalar property (such as an int or a float ). |
void |
updateFromSnapshot(NSDictionary snapshot)
Takes the values from snapshot , and sets the receiver's properties to them. |
String |
userPresentableDescription()
Returns a short (no longer than 60 characters) description of an enterprise object based on its data by calling EOClassDescription's userPresentableDescriptionForObject method |
static boolean |
usesDeferredFaultCreation()
Conformance to EODeferredFaulting. |
void |
validateClientUpdate()
Validate whether object is in an consistent state after being updated from a client. |
void |
validateForDelete()
Confirms that the receiver can be deleted in its current state, throwing an NSValidation.ValidationException if it can't. |
void |
validateForInsert()
Confirms that the receiver can be inserted in its current state, throwing an NSValidation.ValidationException if it can't. |
void |
validateForSave()
Confirms that the receiver can be saved in its current state, throwing an NSValidation.ValidationException if it can't. |
void |
validateForUpdate()
Confirms that the receiver can be saved in its current state, throwing a NSValidation.ValidationException if it can't. |
Object |
validateTakeValueForKeyPath(Object value,
String keyPath)
Confirms that value is valid for the receiver's property named by keyPath , and assigns the value to the property (if value is different from the current value), or throws an NSValidation.ValidationException if value
isn't valid. |
Object |
validateValueForKey(Object value,
String key)
Validates a property indirectly by name. |
Object |
valueForKey(String key)
Returns the receiver's value for the property identified by key . |
Object |
valueForKeyPath(String keyPath)
Returns the value for the derived property identified by keyPath . |
NSDictionary |
valuesForKeys(NSArray keys)
Returns an NSDictionary containing the property values identified by each element in keys . |
NSDictionary |
valuesForKeysWithMapping(NSDictionary mapping)
Returns an NSDictionary containing the property values identified by each of the key-value pairs in mapping . |
void |
willChange()
Notifies any observers that the receiver's state is about to change, by sending each an objectWillChange message. |
void |
willRead()
Fills the receiver with values fetched from the database. |
Object |
willReadRelationship(Object object)
Enterprise object instances that use deferred faulting invoke this method before accessing a relationship to ensure that the relationship isn't a deferred fault. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
@Deprecated public EOCustomObject(EOEditingContext editingContext, EOClassDescription classDescription, EOGlobalID gid)
public EOCustomObject()
Method Detail |
---|
public final Object opaqueState()
EOEnterpriseObject
opaqueState
in interface EOEnterpriseObject
public final boolean equals(Object other)
equals
in class Object
other
- input object against which this object is compared
true
if the objects are equal; false
otherwiseObject.equals(java.lang.Object)
,
EOGlobalID.equals(java.lang.Object)
public int hashCode()
hashCode
in class Object
Object.hashCode()
,
EOCustomObject.equals(java.lang.Object)
public String toString()
eoDescription
.
toString
in class Object
eoDescription
public EOEditingContext editingContext()
null
if none is set.
editingContext
in interface EOEnterpriseObject
EOEditingContext
public void willChange()
objectWillChange
message. A subclass should not override this method, but should invoke it prior to altering the subclass's state, most typically in "set" methods such as the following:
<blockquote>
public void setRoleName(String value) {
willChange();
roleName = value;
}
</blockquote>
willChange
in interface EOEnterpriseObject
EOObserverCenter
public EOClassDescription classDescription()
classDescriptionForClass
.
classDescription
in interface EOEnterpriseObject
EOClassDescription.classDescriptionForClass(Class c)
,
EOCustomObject.classDescription()
,
EOGenericRecord.classDescription()
public String entityName()
entityName
message to the receiver's EOClassDescription.
entityName
in interface EOEnterpriseObject
public NSArray attributeKeys()
attributeKeys
in the object's EOClassDescription and returns the results. You might wish to override this method to add keys for attributes not defined by the EOClassDescription. The access
layer's subclass of EOClassDescription, EOEntityClassDescription
, returns the names of attributes designated as class properties.
attributeKeys
in interface EOEnterpriseObject
EOEnterpriseObject.toOneRelationshipKeys()
,
EOEnterpriseObject.toManyRelationshipKeys()
public NSArray toOneRelationshipKeys()
toOneRelationshipKeys
in the object's EOClassDescription and returns the results. You might wish to override this method to add keys for relationships not defined by the EOClassDescription, but it's rarely
necessary: The access layer's subclass of EOClassDescription, EOEntityClassDescription
, returns the names of to-one relationships designated as class properties.
toOneRelationshipKeys
in interface EOEnterpriseObject
EOCustomObject.attributeKeys()
,
EOCustomObject.toOneRelationshipKeys()
public NSArray toManyRelationshipKeys()
toManyRelationshipKeys()
in the object's EOClassDescription and returns the results. You might wish to override this method to add keys for relationships not defined by the EOClassDescription, but it's rarely
necessary: The access layer's subclass of EOClassDescription, EOEntityClassDescription
, returns the names of to-many relationships designated as class properties.
toManyRelationshipKeys
in interface EOEnterpriseObject
EOCustomObject.toOneRelationshipKeys()
,
EOCustomObject.attributeKeys()
public String inverseForRelationshipKey(String relationshipKey)
relationshipKey
, or null
if there isn't one. With the access layer's EOEntity
and EORelationship
, for example, reciprocality is
determined by the join attributes of the two EORelationships
. EOCustomObject's implementation simply sends an inverseForRelationshipKey
message to the receiver's EOClassDescription.
inverseForRelationshipKey
in interface EOEnterpriseObject
relationshipKey
- the String name of the relationship
public int deleteRuleForRelationshipKey(String relationshipKey)
relationshipKey
when the receiver is deleted. The delete rule is one of:
EOCustomObject's implementation of this method simply sends a deleteRuleForRelationshipKey
message to the receiver's EOClassDescription.
deleteRuleForRelationshipKey
in interface EOEnterpriseObject
relationshipKey
- identifies the receiver's relationship.
EOClassDescription.deleteRuleForRelationshipKey(String relationshipKey)
public boolean ownsDestinationObjectsForRelationshipKey(String relationshipKey)
true
if the receiver has a relationship identified by key
that owns its destination, and false
otherwise. If an object owns the destination for a relationship, then when that destination object is removed from the relationship, it's
automatically deleted. Ownership of a relationship thus contrasts with a delete rule, in that the first applies when the destination is removed and the second applies when the source is deleted. EOCustomObject's implementation of this method simply sends an
ownsDestinationObjectsForRelationshipKey
message to the receiver's EOClassDescription.
ownsDestinationObjectsForRelationshipKey
in interface EOEnterpriseObject
relationshipKey
- Identifies the relationship of the receiver.
EOEnterpriseObject.deleteRuleForRelationshipKey(String relationshipKey)
,
EORelationship.ownsDestination()
public EOClassDescription classDescriptionForDestinationKey(String detailKey)
detailKey
. EOCustomObject's implementation sends a classDescriptionForDestinationKey
message to the receiver's EOClassDescription.
classDescriptionForDestinationKey
in interface EOEnterpriseObject
detailKey
- Identifies relationship of the destination objects.
public void awakeFromInsertion(EOEditingContext ec)
ec
. This is commonly used to assign default values or record the time of insertion. EOCustomObject's implementation merely sends an awakeObjectFromInsertion
to the receiver's EOClassDescription. Subclasses should invoke super
's implementation before performing their own initialization.
awakeFromInsertion
in interface EOEnterpriseObject
ec
- An EOEditingContext object.public void awakeFromFetch(EOEditingContext ec)
ec
. EOCustomObject's implementation merely sends an awakeObjectFromFetch
to the receiver's EOClassDescription. Subclasses
should invoke super's implementation before performing their own initialization.
awakeFromFetch
in interface EOEnterpriseObject
ec
- An EOEditingContext object.public NSDictionary snapshot()
null
. For to-many relationships, the dictionary contains shallow
copies of the arrays. EOCustomObject's implementation should be sufficient for all purposes; you shouldn't have to override this method.
snapshot
in interface EOEnterpriseObject
EOEnterpriseObject.updateFromSnapshot(NSDictionary aSnapshot)
public void updateFromSnapshot(NSDictionary snapshot)
snapshot
, and sets the receiver's properties to them. EOCustomObject's implementation sets each one using takeStoredValueForKey
. In the process, EONullValues are converted to null
, and array values are set as shallow
mutable copies.
updateFromSnapshot
in interface EOEnterpriseObject
snapshot
- the receiver's properties are set to the values taken from thisEOEnterpriseObject.snapshot()
public NSDictionary changesFromSnapshot(NSDictionary snapshot)
snapshot
, and whose values are the uncommitted values. In both snapshot
and the returned dictionary, where a key represents a to-many relationship the
corresponding value is a NSArray containing two other NSArrays: the first is an array of objects to be added to the relationship property, and the second is an array of objects to be removed.
changesFromSnapshot
in interface EOEnterpriseObject
snapshot
- An NSDictionary whose keys are those of the receiver's attributes.
snapshot
EOEnterpriseObject.snapshot()
,
EOEnterpriseObject.reapplyChangesFromDictionary(NSDictionary changes)
,
EOEditingContext.currentEventSnapshotForObject(EOEnterpriseObject object)
,
EOEditingContext.committedSnapshotForObject(EOEnterpriseObject object)
public void reapplyChangesFromDictionary(NSDictionary changes)
takeValuesFromDictionary
, but the changes
dictionary can contain arrays for to-many relationships. A key represents a to-many relationship, the dictionary's value is an NSArray containing two other NSArrays: the first is an array of objects to be
added to the relationship property, and the second is an array of objects to be removed. EOCustomObject's implementation should be sufficient for all purposes; you shouldn't have to override this method.
reapplyChangesFromDictionary
in interface EOEnterpriseObject
changes
- an NSDictionary that contain arrays for to-many relationshipsEOEnterpriseObject.snapshot()
,
EOEnterpriseObject.changesFromSnapshot(NSDictionary snapshot)
,
EOEditingContext.currentEventSnapshotForObject(EOEnterpriseObject object)
,
EOEditingContext.committedSnapshotForObject(EOEnterpriseObject object)
public boolean isToManyKey(String key)
true
if the receiver has a to-many relationship identified by key
, false
otherwise. EOCustomObject's implementation of this method simply checks its toManyRelationshipKeys
array for key.
isToManyKey
in interface EOEnterpriseObject
key
- Identifies the to-many relationship of the receiver.
EOEnterpriseObject.toManyRelationshipKeys()
public NSArray allPropertyKeys()
attributeKeys
, toOneRelationshipKeys
, and toManyRelationshipKeys
.
allPropertyKeys
in interface EOEnterpriseObject
EOEnterpriseObject.attributeKeys()
,
EOEnterpriseObject.toOneRelationshipKeys()
,
EOEnterpriseObject.toManyRelationshipKeys()
public void clearProperties()
null
. EOEditingContext's use this method to break cyclic references among objects when they're finalized. EOCustomObject's implementation should be sufficient for all purposes. If the enterprise object maintains
references to other objects and these references are not to-one or to-many keys, then you should probably subclass this method ensure unused objects can be finalized.
clearProperties
in interface EOEnterpriseObject
public void propagateDeleteWithEditingContext(EOEditingContext ec)
propagateDeleteForObject
message to the receiver's EOClassDescription.
propagateDeleteWithEditingContext
in interface EOEnterpriseObject
ec
- the EOEditingContext containing the objectsEOClassDescription.deleteRuleForRelationshipKey(String relationshipKey)
public String userPresentableDescription()
userPresentableDescriptionForObject
method
userPresentableDescription
in interface EOEnterpriseObject
EOEnterpriseObject.eoDescription()
,
EOEnterpriseObject.eoShallowDescription()
,
EOEnterpriseObject.attributeKeys()
public String eoShallowDescription()
eoDescription
, but doesn't descend into relationships. eoDescription
invokes this method for relationship destinations to avoid infinite recursion through cyclical relationships. EOCustomObject's implementation simply returns a String containing the
receiver's class and entity names.
eoShallowDescription
in interface EOEnterpriseObject
EOEnterpriseObject.userPresentableDescription()
,
EOEnterpriseObject.eoDescription()
public String eoDescription()
eoShallowDescription
message (to avoid infinite recursion through cyclical
relationships).
eoDescription
in interface EOEnterpriseObject
EOCustomObject.eoShallowDescription()
,
EOCustomObject.userPresentableDescription()
public Object invokeRemoteMethod(String methodName, Class[] argumentTypes, Object[] arguments)
invokeRemoteMethod
in interface EOEnterpriseObject
methodName
- the name of the method to be invokedargumentTypes
- Array containing the types of argumentsarguments
- Array containing the arguments.
public void prepareValuesForClient()
prepareValuesForClient
in interface EOEnterpriseObject
public void awakeFromClientUpdate(EOEditingContext ec)
awakeFromClientUpdate
in interface EOEnterpriseObject
ec
- the EOEditingContext of the enterprise object.protected void includeObjectIntoPropertyWithKey(Object eo, String key)
key
the object eo
without affecting inverse relationships, by directly modifying the property storing the to-many relationship. This method can be used from inside of methods of the form addToKey
.
eo
- the object to add to the relationshipkey
- the name of the relationshippublic void addObjectToPropertyWithKey(Object eo, String key)
key
the object eo
without setting inverse relationships. Attempts to invoke a method of the form addToKey
. If the receiver doesn't have such a method, this method gets the property array using
valueForKey
and operates directly on that (adds the object to the array).
addObjectToPropertyWithKey
in interface EORelationshipManipulation
eo
- the object to add to the relationshipkey
- the name of the relationshipprotected void excludeObjectFromPropertyWithKey(Object eo, String key)
eo
from the to-many relationship named key
without affecting inverse relationships, by directly modifying the property storing the to-many relationship. This method can be used from inside of methods of the form removeFromKey
.
The method throws an IllegalArgumentException when attempting to remove an object not contained in the relationship array.
eo
- the object to remove from the relationship.key
- the name of the relationship
IllegalArgumentException
- if eo
is not in relationship key
public void removeObjectFromPropertyWithKey(Object eo, String key)
eo
from the to-many relationship named key
without affecting inverse relationships. Attempts to invoke a method of the form removeFromKey
. If the receiver doesn't have such a method, this method gets the property array using
valueForKey
and removes the object if present. The method throws an IllegalArgumentException when attempting to remove an object not contained in the relationship array.
removeObjectFromPropertyWithKey
in interface EORelationshipManipulation
eo
- the object to remove from the relationship.key
- the name of the relationship
IllegalArgumentException
- if eo
is not in relationship key
public void addObjectToBothSidesOfRelationshipWithKey(EORelationshipManipulation object, String key)
object
as the destination for the receiver's relationship identified by key
, and also sets or adds the receiver for object
's reciprocal relationship if there is one. For a to-one relationship, object
is set using
takeValueForKey
. For a to-many relationship, object
is added using addObjectToPropertyWithKey
. This method also properly handles removing this
and object
from their previous relationship as needed. For example, if an
Employee object belongs to the Research department, invoking this method with the Maintenance department removes the Employee from the Research department as well as setting the Employee's department to Maintenance.
addObjectToBothSidesOfRelationshipWithKey
in interface EORelationshipManipulation
object
- instance to be added to the destination relationshipkey
- name of relationship(Object anObject, String key)
public void removeObjectFromBothSidesOfRelationshipWithKey(EORelationshipManipulation object, String key)
object
from the receiver's relationship identified by key
, and also removes the receiver from objects
's reciprocal relationship if there is one. For a to-one relationship, object
is removed using
takeValueForKey
with null
as the value. For a to-many relationship, object
is removed using removeObjectFromPropertyWithKey
.
removeObjectFromBothSidesOfRelationshipWithKey
in interface EORelationshipManipulation
object
- object to be removed from the receiver's relationshipkey
- name of the relationship.(Object anObject, String key)
public static boolean usesDeferredFaultCreation()
public void willRead()
willRead
prior to any attempt to access the object's state,
most typically in "get" methods such as the following:
<blockquote>
public String roleName() {
willRead();
return roleName;
}
</blockquote>
This methods locks the parent EOObjectStore of the EOEditingContext this EO is contained within for the duration of this method.
willRead
in interface EOFaulting
public boolean isFault()
isFault
in interface EOFaulting
EOFaultHandler.isFault(Object)
public void clearFault()
null
. This method is rarely used directly. Rather, it's invoked by an EOFaultHandler
during the process of firing the fault.
clearFault
in interface EOFaulting
EOFaultHandler
public void turnIntoFault(EOFaultHandler handler)
handler
as the object that stores its original state and later converts the fault back into a normal object (typically by fetching data from an external repository). The receiver becomes the owner of handler
; it
shouldn't be assigned to another object.
turnIntoFault
in interface EOFaulting
handler
- an EOFaultHandler that stores receiver's original state and later converts the fault back into a normal objectEOFaultHandler.makeObjectIntoFault(Object, EOFaultHandler)
public EOFaultHandler faultHandler()
faultHandler
in interface EOFaulting
null
.EOFaultHandler.handlerForFault(Object)
public Object willReadRelationship(Object object)
willReadRelationship
in interface EODeferredFaulting
object
- the object that is checked
EOFaultHandler.createFaultForDeferredFault(Object fault,
EOEnterpriseObject eo)
public Object validateValueForKey(Object value, String key) throws NSValidation.ValidationException
It searches for a method of the form validateKey
and invokes it if it exists. These are the methods that your custom classes can implement to validate individual properties, such as validateAge
to check that the value the user entered is within acceptable limits.
The validateAge
method should raise an EOValidation.Exception
if it finds an unacceptable value.
validateValueForKey
in interface NSValidation
value
- the value to validatekey
- the key corresponding to the object property that will hold the value
NSValidation.ValidationException
- if value isn't legalNSKeyValueCoding.valueForKey(String key)
public Object validateTakeValueForKeyPath(Object value, String keyPath) throws NSValidation.ValidationException
value
is valid for the receiver's property named by keyPath
, and assigns the value to the property (if value
is different from the current value), or throws an NSValidation.ValidationException
if value
isn't valid.
A key path has the form relationship.property (with one or more relationships); for example "movieRole.roleName" or "movieRole.talent.lastName".
validateTakeValueForKeyPath
in interface NSValidation
value
- the value to validatekeyPath
- the keypath that will contain the value
NSValidation.ValidationException
- if value isn't legalNSKeyValueCoding.valueForKey(String key)
public void validateForSave() throws NSValidation.ValidationException
NSValidation.ValidationException
if it can't. EOCustomObject's implementation sends the receiver's EOClassDescription a validateObjectForSave
message, then iterates through all of the
receiver's properties. If this results in more than one exception, the Exception returned contains the additional ones in its userInfo
dictionary under NSValidation.ValidationException.AdditionalExceptionsKey
. Subclasses should invoke super
's
implementation before performing their own validation, and should combine any Exception thrown by super
's implementation with their own.
validateForSave
in interface EOValidation
NSValidation.ValidationException
- if the receiver can't be saved in its current state.NSValidation.ValidationException
public void validateForDelete() throws NSValidation.ValidationException
NSValidation.ValidationException
if it can't. For example, an object can't be deleted if it has a relationship with a delete rule of EOClassDescription.DeleteRuleDeny
and that
relationship has a destination object.
EOCustomObject's implementation sends the receiver's EOClassDescription a message (which performs basic checking based on the presence or absence of values). Subclasses should invoke super
's implementation before performing their own validation, and should combine any
Exception thrown by super
's implementation with their own.
validateForDelete
in interface EOValidation
NSValidation.ValidationException
- if the receiver can't be deleted in its current state.EOEnterpriseObject.propagateDeleteWithEditingContext( EOEditingContext ec)
public void validateForInsert() throws NSValidation.ValidationException
NSValidation.ValidationException
if it can't. EOCustomObject's implementation simply invokes validateForSave
.
The method validateForSave
is the generic validation method for when an object is written to the external store. If an object performs validation that isn't specific to insertion, it should go in validateForSave
.
validateForInsert
in interface EOValidation
NSValidation.ValidationException
- if the receiver can't be inserted in its current state.EOCustomObject.validateForSave()
public void validateForUpdate() throws NSValidation.ValidationException
NSValidation.ValidationException
if it can't. EOCustomObject's implementation simply invokes validateForSave
.
The method validateForSave
is the generic validation method for when an object is written to the external store. If an object performs validation that isn't specific to updating, it should go in validateForSave
.
validateForUpdate
in interface EOValidation
NSValidation.ValidationException
- if the receiver can't be saved in its current state.EOCustomObject.validateForSave()
public void validateClientUpdate() throws NSValidation.ValidationException
validateClientUpdate
in interface EOValidation
NSValidation.ValidationException
public static boolean canAccessFieldsDirectly()
false
if the key-value coding methods should never access the corresponding instance variable directly on finding no accessor method for a property.
EOCustomObject.valueForKey(String key)
,
EOCustomObject.takeValueForKey(Object value, String key)
public Object valueForKey(String key)
key
.
The default implementation provided by NSKeyValueCoding.DefaultImplementation
works as follows:
key
. For example, with a key
of "lastName", the method looks for a method named getLastName
or lastName
.key
(a method preceded by an underbar). For example, with a key
of "lastName", the method looks for a method named _getLastName
or _lastName
canAccessFieldsDirectly
returns true, the method searches for an instance variable based on key
and returns its value directly. For the key
"lastName", this would be
_lastName
or lastName
.handleQueryWithUnboundKey
(defined in NSKeyValueCoding.ErrorHandling
).NSKeyValueCoding
provided by the Foundation package should always be used. The default implementations have significant performance optimizations. To benefit from them, implement NSKeyValueCoding
on a custom class as shown
above by using the methods in NSKeyValueCoding.DefaultImplementation
; or if the class inherits from an WebObjects class that implements NSKeyValueCoding
, the inherited implementation is not to be overridden. Using a custom implementation incurs significant
performance penalties.
valueForKey
in interface NSKeyValueCoding
key
- a property of the receiver
NSKeyValueCoding.NullValue
,
NSKeyValueCoding.takeValueForKey(java.lang.Object, java.lang.String)
,
NSKeyValueCoding.DefaultImplementation
,
NSKeyValueCoding.ErrorHandling
,
NSKeyValueCoding.ErrorHandling.handleQueryWithUnboundKey(java.lang.String)
public void takeValueForKey(Object value, String key)
key
to value
.
The default implementation provided by NSKeyValueCoding.DefaultImplementation
works as follows:
setKey
, and invokes it if there is one._setKey
, and invokes it if there is one.canAccessFieldsDirectly
returns true, searches for an instance variable based on key and sets its value directly. For the key "lastName", this would be _lastName
or lastName
. handleTakeValueForUnboundKey
if the object implements NSKeyValueCoding.ErrorHandling
or throws NSKeyValueCoding.UnknownKeyException
if the
object doesn't.NSKeyValueCoding
provided by the Foundation package should always be used. The default implementations have significant performance optimizations. To benefit from them, implement NSKeyValueCoding
on a custom class as shown
above by using the methods in NSKeyValueCoding.DefaultImplementation
; or if the class inherits from an WebObjects class that implements NSKeyValueCoding
, the inherited implementation is not to be overridden. Using a custom implementation incurs significant
performance penalties.
takeValueForKey
in interface NSKeyValueCoding
value
- The receiver's value for the property key is set to this.key
- Identifies the property of the receiver.
NSKeyValueCoding.UnknownKeyException
- if the object doesn't implements NSKeyValueCoding.ErrorHandling.NSKeyValueCoding.NullValue
,
NSKeyValueCoding.valueForKey
,
NSKeyValueCoding.DefaultImplementation
,
NSKeyValueCoding.ErrorHandling
,
NSKeyValueCoding.ErrorHandling.handleTakeValueForUnboundKey(java.lang.Object, java.lang.String)
public Object handleQueryWithUnboundKey(String key)
valueForKey
when it finds no property binding for key
. The default implementation throws an NSKeyValueCoding.UnknownKeyException, with the target object(TargetObjectUserInfoKey)
and key(UnknownUserInfokey)
in the user
info. An NSKeyValueCoding.ErrorHandling class can override this method to handle the query in some other way. The method can return a value, in which case that value is returned by the corresponding valueForKey
invocation.
handleQueryWithUnboundKey
in interface NSKeyValueCoding.ErrorHandling
key
- the key that was not found
valueForKey
invocationEOCustomObject.valueForKey(String key)
,
NSKeyValueCoding.DefaultImplementation
,
NSKeyValueCoding.UnknownKeyException#TargetObjectUserInfoKey
,
NSKeyValueCoding.UnknownKeyException#UnknownUserInfoKey
public void handleTakeValueForUnboundKey(Object value, String key)
takeValueForKey
when it finds no property binding for key
. The default implementation throws an NSKeyValueCoding.UnknownKeyException, with the target object(TargetObjectUserInfoKey)
and key(UnknownUserInfoKey)
in the
user info.
handleTakeValueForUnboundKey
in interface NSKeyValueCoding.ErrorHandling
value
- the value that was attempted to be set for key
key
- they key whose property binding wasn't found in takeValueForKey
EOCustomObject.takeValueForKey(Object value, String key)
,
NSKeyValueCoding.DefaultImplementation
,
NSKeyValueCoding.UnknownKeyException#TargetObjectUserInfoKey
,
NSKeyValueCoding.UnknownKeyException#UnknownUserInfoKey
public void unableToSetNullForKey(String key)
takeValueForKey
when it's given a null
value for a scalar property (such as an int
or a float
). The default implementation throws an IllegalArgumentException
. You might want to implement the method (or
override the inherited implementation) to handle the request in some other way, such as by substituting zero or a sentinel value and invoking takeValueForKey
again.
unableToSetNullForKey
in interface NSKeyValueCoding.ErrorHandling
key
- a property of the receiver.
IllegalArgumentException
- when it's given a null value for a scalar property.NSKeyValueCoding.DefaultImplementation
public Object valueForKeyPath(String keyPath)
keyPath
. A key path has the form relationship.property (with one or more relationships). For example "movieRole.roleName" or "movieRole.talent.lastName". The default implementation of this method (provided by
NSKeyValueCodingAdditions.DefaultImplementation
) gets the destination object for each relationship using valueForKey
, and returns the result of a valueForKey
message to the final object.
valueForKeyPath
in interface NSKeyValueCodingAdditions
keyPath
- Identifies the derived property for the receiver.
NSKeyValueCoding.valueForKey(java.lang.String)
,
NSKeyValueCodingAdditions.takeValueForKeyPath(java.lang.Object, java.lang.String)
,
NSKeyValueCodingAdditions.DefaultImplementation
public void takeValueForKeyPath(Object value, String keyPath)
keyPath
to value
. A key path as the form relationship.property (with one or more relationships).
takeValueForKeyPath
in interface NSKeyValueCodingAdditions
value
- the receiver's property identified by keyPath is set to thiskeyPath
- a property of an objectNSKeyValueCoding.takeValueForKey(java.lang.Object, java.lang.String)
,
NSKeyValueCodingAdditions.valueForKeyPath(java.lang.String)
,
NSKeyValueCodingAdditions.DefaultImplementation
public static boolean shouldUseStoredAccessors()
false
if the stored value methods (storedValueForKey
and takeStoredValueForKey
) should not use private accessor methods in preference to public accessors. Returning false
causes the stored value methods to use the same accessor method instance variable search order as the corresponding basic key-value coding methods (valueForKey
and takeValueForKey
). This method doesn't have to be implemented if the default stored value search
order is correct for the objects.
public Object storedValueForKey(String key)
key
. This method is used when the value is retrieved for storage in an object store (generally, this is ultimately in a database) or for inclusion in a snapshot. The default implementation provided by EOCustomObject is similar
to the implementation of valueForKey
, but it resolves key
with a different method instance variable search order:
key
(a method preceded by an underbar). For example, with a key
of "lastName", storedValueForKey
looks for a method named _getLastName
or _lastName
.key
and returns its value directly. For example, with a key
of "lastName", storedValueForKey
looks for an instance variable named _lastName
or
lastName
.storedValueForKey
searches for a public accessor method based on key
. For the key
"lastName", this would be getLastName
or lastName
.key
is unknown, storedValueForKey
calls handleTakeValueForUnboundKey
.
storedValueForKey
in interface EOKeyValueCoding
key
- a property of receiver.
NSKeyValueCoding
,
NSKeyValueCoding.ErrorHandling
,
NSKeyValueCoding.valueForKey(String)
,
NSKeyValueCoding.ErrorHandling.handleQueryWithUnboundKey(String)
public void takeStoredValueForKey(Object value, String key)
key
to value
. This method is used to initialize the receiver with values from an object store (generally, this is ultimately from a database) or to restore a value from a snapshot. The default implementation provided by
EOCustomObject is similar to the implementation of takeValueForKey
, but it resolves key
with a different method instance variable search order:
key
(a method preceded by an underbar). For example, with a key
of "lastName", takeStoredValueForKey
looks for a method named _setLastName
. key
and sets its value directly. For example, with a key
of "lastName", takeStoredValueForKey
looks for an instance variable named _lastName
or
lastName
.takeStoredValueForKey
searches for a public accessor method based on key
. For the key
"lastName", this would be setLastName
.key
is unknown, takeStoredValueForKey
calls handleTakeValueForUnboundKey
.
This different search order allows an object to bypass processing that is performed before setting a value through public API. However, if it is always wanted to use the search order in takeValueForKey
, you can implement the static method shouldUseStoredAccessors
to return false
. And as with valueForKey
, you can prevent direct access of an instance variable with the static method canAccessFieldsDirectly
.
takeStoredValueForKey
in interface EOKeyValueCoding
value
- the property identified by key is set to this.key
- a property of receiver.EOCustomObject.shouldUseStoredAccessors()
,
EOCustomObject.canAccessFieldsDirectly()
public NSDictionary valuesForKeys(NSArray keys)
keys
. EOCustomObject's implementation invokes valueForKey
for each key in keys
, substituting EONullValues
into the NSDictionary for returned
null
s.
valuesForKeys
in interface EOKeyValueCodingAdditions
keys
- an NSArray of property names in the receiver
NSKeyValueCoding.valueForKey(String)
public NSDictionary valuesForKeysWithMapping(NSDictionary mapping)
mapping
. The keys of the mapping
dictionary represent arbitrary external names for properties of an Enterprise Object and the values are the internal or EOModel
names for these properties. Invokes valueForKey
for each value in mapping
, substituting NSKeyValueCoding.NullValue in the returned dictionary for returned null
s.
valuesForKeysWithMapping
in interface EOKeyValueCodingAdditions
mapping
- the dictionary that maps arbitrary external names to internal property names
mapping
NSKeyValueCoding.valueForKey(String)
public void takeValuesFromDictionary(NSDictionary dictionary)
dictionary
, using its keys to identify the properties. EOCustomObject's implementation invokes takeValueForKey
for each key-value pair, substituting null
for EONullValues
in
aDictionary
.
takeValuesFromDictionary
in interface EOKeyValueCodingAdditions
dictionary
- values from this are taken to set properties of the receiverEOCustomObject.takeValueForKey(Object value, String key)
public void takeValuesFromDictionaryWithMapping(NSDictionary dictionary, NSDictionary mapping)
dictionary
, using its keys and mapping
to identify the properties. mapping
associates the keys of dictionary
, which are arbitrary external names for the properties to be set, with
the internal or EOModel names for those properties. If a key in dictionary
does not have a corresponding entry in mapping
, the external key (i.e., the key from dictionary
) is used.
Invokes takeValueForKey
for each key-value pair of dictionary
, substituting null
for NSKeyValueCoding.NullValue values in the dictionary.
takeValuesFromDictionaryWithMapping
in interface EOKeyValueCodingAdditions
dictionary
- the key-value pairs to be setmapping
- the dictionary that maps arbitrary external names to internal property namesEOCustomObject.takeValueForKey(Object value, String key)
protected Object readResolve() throws ObjectStreamException
ObjectStreamException
public boolean isReadOnly()
EOEnterpriseObject
true
if the receiver can not be modified, false
if it can. If an entity is read-only, then Enterprise Objects fetched for that entity are also read-only (that is, can not be inserted, deleted, or updated).
isReadOnly
in interface EOEnterpriseObject
true
if the entity can't be modified.
|
Last updated June 2008 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |