WebObjects 5.4.2

com.webobjects.eoaccess
Class EOEntityClassDescription

java.lang.Object
  extended by com.webobjects.eocontrol.EOClassDescription
      extended by com.webobjects.eoaccess.EOEntityClassDescription
All Implemented Interfaces:
Serializable

public class EOEntityClassDescription
extends EOClassDescription

EOEntityClassDescription is a subclass of the control layer's EOClassDescription. The EOClassDescription class provides a mechanism for extending classes by giving them access to metadata not available in the runtime system. EOEntityClassDescription extends the behavior of Enterprise Objects by deriving information about them (such as NULL constraints and referential integrity rules) from an associated EOModel.

In the typical scenario in which an Enterprise Object has a corresponding model file, the first time a particular operation is performed on a class (such as validating a value), an EOClassDescriptionNeeded... notification is broadcast. This may be either an EOClassDescriptionNeededForClassNotification or an EOClassDescriptionNeededForEntityNameNotification. When an EOModel object receives this notification it registers the metadata (class description) for the EOEntity on which the Enterprise Object is based. This class description is used from that point on.

See Also:
EOClassDescription, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class com.webobjects.eocontrol.EOClassDescription
EOClassDescription.ClassDelegate
 
Field Summary
 
Fields inherited from class com.webobjects.eocontrol.EOClassDescription
ClassDescriptionNeededForClassNotification, ClassDescriptionNeededForEntityNameNotification, DeleteRuleCascade, DeleteRuleDeny, DeleteRuleNoAction, DeleteRuleNullify
 
Constructor Summary
EOEntityClassDescription(EOEntity entity)
          Creates and returns a new EOEntityClassDescription for entity.
 
Method Summary
 NSArray allAttributeKeys()
          Returns an array of the names of all the attributes of the receiver's entity.
 NSArray allPropertyKeys()
          Returns an array of the names of all the properties for the entity associated with the receiver.
 NSArray allToManyRelationshipKeys()
          Returns an array of the names of all the to-many relationships of the receiver's entity.
 NSArray allToOneRelationshipKeys()
          Returns an array of the names of all the to-one relationships of the receiver's entity.
 NSArray attributeKeys()
          Returns an array of attribute keys for the entity associated with the receiver.
 void awakeObjectFromInsertion(EOEnterpriseObject object, EOEditingContext ec)
          Propagates inserts for the newly-inserted Enterprise Object object in the editing context ec.
 EOClassDescription classDescriptionForDestinationKey(String detailKey)
          Returns the EOClassDescription for objects at the destination of the to-one relationship identified by detailKey.
 Class classForAttributeKey(String key)
           
 NSArray clientAttributeKeys()
          Returns an array containing the names of the attributes that are bound to the client-side class that corresponds to the receiver's entity.
 NSArray clientToManyRelationshipKeys()
          Returns an array containing the names of the to-many relationships that are bound to the client-side class that corresponds to the receiver's entity.
 NSArray clientToOneRelationshipKeys()
          Returns an array containing the names of the to-one relationships that are bound to the client-side class that corresponds to the receiver's entity.
 EOEnterpriseObject createInstanceWithEditingContext(EOEditingContext ec, EOGlobalID gid)
          Creates and returns an Enterprise Object in the editing context ec by using the EOGlobalID gid to query the receiver's EOEntity for the appropriate class of object to instantiate.
 Format defaultFormatterForKey(String key)
          Returns the formatter to use when parsing values for assignment to key.
 int deleteRuleForRelationshipKey(String relationshipKey)
          Returns a delete rule indicating how to treat the destination of the given relationship when the receiver's entity is deleted.
 EOEntity entity()
          Returns the entity associated with the receiver.
 String entityName()
          Returns the name of the entity associated with the receiver.
 EOFetchSpecification fetchSpecificationNamed(String name)
          Returns the fetch specification with the specified name from the receiver's entity.
 String inverseForRelationshipKey(String relationshipKey)
          Returns the name of the relationship pointing back to the receiver's entity from the destination of the relationship specified by relationshipKey.
 boolean isEntityReadOnly()
          Overridden by subclasses to return whether the receiver can be modified.
 boolean ownsDestinationObjectsForRelationshipKey(String relationshipKey)
          Returns true if the the objects at the destination of the relationship specified by relationshipKey should be deleted if they are removed from the relationship rather than transferred to the corresponding relationship of another object.
protected  Object readResolve()
           
 EOClassDescription superClassDescription()
          Returns null.
 NSArray toManyRelationshipKeys()
          Returns an array of keys for the to-many relationship properties of the receiver's entity.
 NSArray toOneRelationshipKeys()
          Returns the keys for the to-one relationship properties of the receiver's entity.
 void validateObjectForDelete(EOEnterpriseObject object)
          Determines whether it is permissible to delete object.
 Exception validateObjectForSave(Object object)
          Returns null.
 Object validateValueForKey(Object valueP, String key)
          Validates the object valueP using the property named key.
 
Methods inherited from class com.webobjects.eocontrol.EOClassDescription
awakeObjectFromFetch, classDelegate, classDescriptionForClass, classDescriptionForEntityName, classDescriptionForKeyPath, defaultFormatterForKeyPath, displayNameForKey, finalize, invalidateClassDescriptionCache, propagateDeleteForObject, registerClassDescription, setClassDelegate, toString, userPresentableDescriptionForObject, validateObjectForSave
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

EOEntityClassDescription

public EOEntityClassDescription(EOEntity entity)
Creates and returns a new EOEntityClassDescription for entity.

Parameters:
entity - An EOEntity object.
See Also:
EOEntityClassDescription.entity()
Method Detail

entityName

public String entityName()
Returns the name of the entity associated with the receiver.

Overrides:
entityName in class EOClassDescription
Returns:
The name of the receiver's EOEntity.
See Also:
EOClassDescription.attributeKeys(), EOClassDescription.toOneRelationshipKeys(), EOClassDescription.toManyRelationshipKeys()

entity

public EOEntity entity()
Returns the entity associated with the receiver.

Returns:
The receiver's EOEntity.

isEntityReadOnly

public boolean isEntityReadOnly()
Description copied from class: EOClassDescription
Overridden by subclasses to return whether the receiver can be modified. Returns 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). The default implementation returns false.

Overrides:
isEntityReadOnly in class EOClassDescription
Returns:
true if the entity can't be modified.

fetchSpecificationNamed

public EOFetchSpecification fetchSpecificationNamed(String name)
Returns the fetch specification with the specified name from the receiver's entity.

Overrides:
fetchSpecificationNamed in class EOClassDescription
Parameters:
name - The name of the fetch specification to retrieve.
Returns:
The fetch specification named name.

superClassDescription

public EOClassDescription superClassDescription()
Returns null.

Overrides:
superClassDescription in class EOClassDescription
Returns:
null.

createInstanceWithEditingContext

public EOEnterpriseObject createInstanceWithEditingContext(EOEditingContext ec,
                                                           EOGlobalID gid)
Creates and returns an Enterprise Object in the editing context ec by using the EOGlobalID gid to query the receiver's EOEntity for the appropriate class of object to instantiate. If the receiver's entity does not have an Enterprise Object class name set, creates and returns an EOGenericRecord object.

Throws an exception if the receiver's entity does have an Enterprise Object class name set and the class for the Enterprise Object identified by gid does not have a publicly accessible constructor.

Overrides:
createInstanceWithEditingContext in class EOClassDescription
Parameters:
ec - The EOEditingContext into which to instantiate the new enterprise object.
gid - The unique identifier of an Enterprise Object belonging to the receiver's entity.
Returns:
The newly created Enterprise Object.
Throws:
IllegalArgumentException - if unable to construct an object for gid.
See Also:
EOEditingContext, EOEntity.className(), EOEntity.setClassName(String name)

classForAttributeKey

public Class classForAttributeKey(String key)
Overrides:
classForAttributeKey in class EOClassDescription

attributeKeys

public NSArray attributeKeys()
Returns an array of attribute keys for the entity associated with the receiver. Attributes contain immutable data (such as Numbers or Strings), as opposed to relationships, which are references to other Enterprise Objects.

Overrides:
attributeKeys in class EOClassDescription
Returns:
An array of the receiver's entity's attribute keys.
See Also:
EOEntity.attributes()

toOneRelationshipKeys

public NSArray toOneRelationshipKeys()
Returns the keys for the to-one relationship properties of the receiver's entity. To-one relationships are references other Enterprise Objects.

Overrides:
toOneRelationshipKeys in class EOClassDescription
Returns:
An array of keys for the to-one relationship properties of the receiver's entity.
See Also:
EOClassDescription.entityName(), EOClassDescription.attributeKeys(), EOClassDescription.toManyRelationshipKeys()

toManyRelationshipKeys

public NSArray toManyRelationshipKeys()
Returns an array of keys for the to-many relationship properties of the receiver's entity. To-many relationship properties contain arrays of Enterprise Objects.

Overrides:
toManyRelationshipKeys in class EOClassDescription
Returns:
An array of keys for the to-many relationships of the receiver's entity.
See Also:
EOClassDescription.entityName(), EOClassDescription.toOneRelationshipKeys(), EOClassDescription.attributeKeys()

clientAttributeKeys

public NSArray clientAttributeKeys()
Returns an array containing the names of the attributes that are bound to the client-side class that corresponds to the receiver's entity.

Overrides:
clientAttributeKeys in class EOClassDescription
Returns:
An array of the names of the client-side attributes of the receiver's entity.

clientToOneRelationshipKeys

public NSArray clientToOneRelationshipKeys()
Returns an array containing the names of the to-one relationships that are bound to the client-side class that corresponds to the receiver's entity.

Overrides:
clientToOneRelationshipKeys in class EOClassDescription
Returns:
An array of names of the client-side to-one relationships of the receiver's entity.

clientToManyRelationshipKeys

public NSArray clientToManyRelationshipKeys()
Returns an array containing the names of the to-many relationships that are bound to the client-side class that corresponds to the receiver's entity.

Overrides:
clientToManyRelationshipKeys in class EOClassDescription
Returns:
An array of names of the client-side to-many relationships of the receiver's entity.

inverseForRelationshipKey

public String inverseForRelationshipKey(String relationshipKey)
Returns the name of the relationship pointing back to the receiver's entity from the destination of the relationship specified by relationshipKey. Returns null if relationshipKey can not be resolved to a valid relationship in the entity's model, or if a valid inverse relationship can not be found.

For example, suppose an Employee object has a relationship called department to a Department object, and Department has a relationship called employees back to Employee. Invoking inverseForRelationshipKey on an instance of Employee with the argument "department" will return the string "employees".

Overrides:
inverseForRelationshipKey in class EOClassDescription
Parameters:
relationshipKey - The name of a relationship owned by the receiver's entity.
Returns:
The name of the relationship pointing back at to receiver from the destination object of the relationship specified by relationshipKey, or null.

deleteRuleForRelationshipKey

public int deleteRuleForRelationshipKey(String relationshipKey)
Returns a delete rule indicating how to treat the destination of the given relationship when the receiver's entity is deleted. The delete rule is one of:

In the common case, the delete rule for an Enterprise Object is defined in its EOModel.

Overrides:
deleteRuleForRelationshipKey in class EOClassDescription
Parameters:
relationshipKey - The name of a relationship of the receiver's entity.
Returns:
The delete rule for the specified relationship.
See Also:
EOModel, EORelationship

ownsDestinationObjectsForRelationshipKey

public boolean ownsDestinationObjectsForRelationshipKey(String relationshipKey)
Returns true if the the objects at the destination of the relationship specified by relationshipKey should be deleted if they are removed from the relationship rather than transferred to the corresponding relationship of another object. Returns false otherwise.

For example, an Invoice object owns its line items. If a LineItem object is removed from an Invoice, it should be deleted since it can not exist outside of an Invoice. In the common case, this behavior for an Enterprise Object is defined in its EOModel.

Overrides:
ownsDestinationObjectsForRelationshipKey in class EOClassDescription
Parameters:
relationshipKey - The name of a relationship of the receiver's entity.
Returns:
true if destination objects should be deleted.

allPropertyKeys

public NSArray allPropertyKeys()
Returns an array of the names of all the properties for the entity associated with the receiver. These properties include both relationships and attributes.

Returns:
An array of all property names for the receiver's entity.

classDescriptionForDestinationKey

public EOClassDescription classDescriptionForDestinationKey(String detailKey)
Returns the EOClassDescription for objects at the destination of the to-one relationship identified by detailKey. Throws a runtime exception if an error is encountered while resolving the relationship or its destination entity; the error text indicates the nature of the exception.

Overrides:
classDescriptionForDestinationKey in class EOClassDescription
Parameters:
detailKey - The name of a to-one relationship of the receiver's entity.
Returns:
The class description for the destination objects of the relationship named detailKey.

validateValueForKey

public Object validateValueForKey(Object valueP,
                                  String key)
                           throws NSValidation.ValidationException
Validates the object valueP using the property named key. If key can be resolved to an attribute of the receiver's entity, that attribute will attempt to validate valueP. Otherwise, if key can be resolved to a relationship of the receiver's entity, that relationship will attempt to validate valueP. In either case, the validating property will return valueP unchanged if validation was successful and no conversion was required or will return the coerced value if valueP required some type of conversion and validation was successful.

If key is not the name of a property of the receiver's entity, valueP is returned unchanged. Throws an exception if any error occurs during validation.

Overrides:
validateValueForKey in class EOClassDescription
Parameters:
valueP - The value to be validated.
key - The name of an attribute or relationship of the receiver's entity.
Returns:
The validated value (either the original value or the converted value).
Throws:
NSValidation.ValidationException - if validation fails.
See Also:
EOAttribute.validateValue(Object valueP), EORelationship.validateValue(Object valueP), EOValidation

validateObjectForSave

public Exception validateObjectForSave(Object object)
Returns null.

Parameters:
object - An object to be validated.
Returns:
null

awakeObjectFromInsertion

public void awakeObjectFromInsertion(EOEnterpriseObject object,
                                     EOEditingContext ec)
Propagates inserts for the newly-inserted Enterprise Object object in the editing context ec. If object has one or more relationships that propagate the primary key and if no object yet exists at the destination of those relationships, a new object is created at the destination. Use this method to put default values in the new Enterprise Object.

Overrides:
awakeObjectFromInsertion in class EOClassDescription
Parameters:
object - An Enterprise Object newly inserted into ec.
ec - The editing context to which object belongs.

validateObjectForDelete

public void validateObjectForDelete(EOEnterpriseObject object)
                             throws NSValidation.ValidationException
Determines whether it is permissible to delete object. If the delete operation can proceed, this method returns normally. If the delete operation should not proceed, an NSValidation.ValidationException is thrown. Validation for deletion will fail if the delete rule for any relationship owned by object is DeleteRuleDeny and there are related destination objects.

Overrides:
validateObjectForDelete in class EOClassDescription
Parameters:
object - An Enterprise Object to be deleted.
Throws:
NSValidation.ValidationException - if the delete operation should not proceed.

defaultFormatterForKey

public Format defaultFormatterForKey(String key)
Returns the formatter to use when parsing values for assignment to key. The formatter is based on the Java value class specified for key in the associated model file. Returns null if the value class is not matched.

Overrides:
defaultFormatterForKey in class EOClassDescription
Parameters:
key - The name of an attribute to format.
Returns:
The Format object to use when parsing values for assignment to key.

allAttributeKeys

public NSArray allAttributeKeys()
Returns an array of the names of all the attributes of the receiver's entity.

Returns:
An array of all the receiver's entity's attribute names.

allToOneRelationshipKeys

public NSArray allToOneRelationshipKeys()
Returns an array of the names of all the to-one relationships of the receiver's entity. Returns an empty array if there are no to-one relationships.

Returns:
An array of all the receiver's entity's to-one relationship names.

allToManyRelationshipKeys

public NSArray allToManyRelationshipKeys()
Returns an array of the names of all the to-many relationships of the receiver's entity. Returns an empty array if there are no to-many relationships.

Returns:
An array of all the receiver's entity's to-many relationship names.

readResolve

protected Object readResolve()
                      throws ObjectStreamException
Throws:
ObjectStreamException

Last updated June 2008

Copyright © 2000-2008 Apple Inc.