|
WebObjects 5.2.3 | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.webobjects.eocontrol.EOClassDescription
EOClassDescription provides a mechanism for extending classes with additional meta-data useful for interacting with Enterprise Objects. It also allows this meta-information to be registered at runtime by an external source (e.g. an EOEntity). In effect, the EOClassDescription allows EOF to add useful behavior to your by EOs using information specified for the EO in the EOModel file.
For example, the Java runtime allows the list of methods and instance
variables for a class to be queried ("introspected") at runtime (this is what makes
possible the EOKeyValueCoding interface). However, it does not provide information
on whether the property of an object is an attribute or relationship, nor
whether that relationship points to one or to many objects -- this information
is not available in the source code, but it is available in the EOModel (in EOAccess).
Note, though, that although the EOModel is the most common source of an
EOClassDescription for a class, it is not the only one. Objects that don't
have a model can implement methods like relationshipKeys
and attributeKeys
directly as instance methods, and the rest of the Framework can treat them
identically to EOs that have this information provided by an external model.
For more information on EOClassDescription, refer to:
ClassDescriptionNeededForClassNotification
,
ClassDescriptionNeededForEntityNameNotification
,
EOEntity
,
EOClassDescription.ClassDelegate.shouldPropagateDeleteForObject(com.webobjects.eocontrol.EOEnterpriseObject, com.webobjects.eocontrol.EOEditingContext, java.lang.String)
,
Serialized FormNested Class Summary | |
static interface |
EOClassDescription.ClassDelegate
The ClassDelegate interface defines a method that the EOClassDescription class can invoke in its delegate. |
Field Summary | |
static String |
ClassDescriptionNeededForClassNotification
Used to extend the behavior of Enterprise Objects in classDescription . |
static String |
ClassDescriptionNeededForEntityNameNotification
When classDescriptionForEntityName is invoked for a previously unregistered
entity name, this notification is broadcast with the requested entity name
as the object of the notification. |
static int |
DeleteRuleCascade
Delete destination objects when the source object is deleted. |
static int |
DeleteRuleDeny
Refuse delete operation if the source object has any destination objects. |
static int |
DeleteRuleNoAction
When the source object is deleted, its relationship to destination objects is ignored. |
static int |
DeleteRuleNullify
When the source object is deleted, any destination object's references back to it are set to null . |
Constructor Summary | |
EOClassDescription()
|
Method Summary | |
NSArray |
attributeKeys()
Overridden by subclasses to return an array of attribute keys for objects described by the receiver.Attributes contain immutable data (such as Numbers and Strings), as opposed to relationships that are references to other enterprise objects. |
void |
awakeObjectFromFetch(EOEnterpriseObject object,
EOEditingContext editingContext)
Overridden by subclasses to perform standard post fetch initialization for object in editingContext . |
void |
awakeObjectFromInsertion(EOEnterpriseObject object,
EOEditingContext editingContext)
Assigns empty arrays to to many relationship properties of newly inserted enterprise objects. |
static Object |
classDelegate()
|
static EOClassDescription |
classDescriptionForClass(Class aClass)
Invoked by the default implementations of the EOEnterpriseObject interface method classDescription . |
EOClassDescription |
classDescriptionForDestinationKey(String detailKey)
Overridden by subclasses to return the class description for objects at the destination of the to-one relationship identified by detailKey . |
static EOClassDescription |
classDescriptionForEntityName(String entityName)
Gets the EOClassDescription registered under entityName . |
EOClassDescription |
classDescriptionForKeyPath(String key)
|
Class |
classForAttributeKey(String key)
|
NSArray |
clientAttributeKeys()
Enables you to find attributes names that are bound to the client-side class that corresponds to the receiver's entity. |
NSArray |
clientToManyRelationshipKeys()
Used to determine the to many relationships that are bound to the client side class that corresponds to the receiver's entity. |
NSArray |
clientToOneRelationshipKeys()
Used to determine the to-one relationships that are bound to the client side class that corresponds to the receiver's entity. |
EOEnterpriseObject |
createInstanceWithEditingContext(EOEditingContext editingContext,
EOGlobalID globalID)
Overridden by subclasses to create an object of the appropriate class in editingContext with globalID . |
Format |
defaultFormatterForKey(String key)
The EOAccess layer's EOEntityClassDescription's implementation returns a Format based on the Java value class specified for key in the associated model file. |
Format |
defaultFormatterForKeyPath(String keyPath)
Similar to defaultFormatterForKey , except this method traverses
keyPath before returning the formatter for the key at the end of the
path. |
int |
deleteRuleForRelationshipKey(String relationshipKey)
Overridden by subclasses to return a delete rule indicating how to treat the destination of the given relationship when the receiving object is deleted. |
String |
displayNameForKey(String key)
Provides a means to display a key in the user interface. |
String |
entityName()
Overridden by subclasses to obtain a unique type name for objects of this class. |
EOFetchSpecification |
fetchSpecificationNamed(String name)
Overridden by subclasses to obtain the fetch specification associated with name . |
void |
finalize()
|
static void |
invalidateClassDescriptionCache()
Flushes the EOClassDescription cache. |
String |
inverseForRelationshipKey(String relationshipKey)
Overridden by subclasses to obtain the name of the relationship back to the receiver from the destination of the relationship specified with relationshipKey . |
boolean |
ownsDestinationObjectsForRelationshipKey(String relationshipKey)
Overridden by subclasses to determine whether the objects at the destination of the relationship specified by relationshipKey should be deleted if they are removed from the
relationship. |
void |
propagateDeleteForObject(EOEnterpriseObject obj,
EOEditingContext ec)
Propagates a delete operation for an object in an EditingContext, according to the delete rules specified in the EOModel. |
static void |
registerClassDescription(EOClassDescription description,
Class aClass)
Registers an EOClassDescription object for a class in the EOClassDescription cache. |
static void |
setClassDelegate(Object delegate)
Sets the delegate for the entire EOClassDescription class. |
EOClassDescription |
superClassDescription()
Overridden by subclasses to return a super class's class description. |
NSArray |
toManyRelationshipKeys()
Overridden by subclasses to determine the to-many relationship properties of the receiver. |
NSArray |
toOneRelationshipKeys()
Overridden by subclasses to determine the to-one relationship properties of the receiver. |
String |
toString()
Returns a String representation of the receiver, including its class name, the name of the entity it describes, and attribute keys and all relationship keys of that entity. |
String |
userPresentableDescriptionForObject(EOEnterpriseObject eo)
Returns a short (no longer than 60 characters) description of an EOEnterpriseObject based on its data. |
void |
validateObjectForDelete(EOEnterpriseObject object)
Overridden by subclasses to determine whether it's permissible to delete an object. |
void |
validateObjectForSave(EOEnterpriseObject object)
Overridden by subclasses to determine whether the values being saved for an object are acceptable. |
Object |
validateValueForKey(Object value,
String key)
Overridden by subclasses to validate a value. |
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final String ClassDescriptionNeededForClassNotification
classDescription
.
The first time an Enterprise Object receives a classDescription
message (for example, when changes to the object are being saved to the
database), it posts ClassDescriptionNeededForClassNotification
to notify observers that a class description is needed. An individual observer
then locates the appropriate class description and registers it in the
application. By default, EOModel objects are registered as observers
for this notification and register EOClassDescriptions on demand.
EOEnterpriseObject.classDescription()
public static final String ClassDescriptionNeededForEntityNameNotification
classDescriptionForEntityName
is invoked for a previously unregistered
entity name, this notification is broadcast with the requested entity name
as the object of the notification. By default, EOModel objects are registered
as observers for this notification and register EOClassDescriptions
on demand. Subscribers can call registerClassDescription()
to
register the class description.
classDescriptionForEntityName(String entityName)
public static final int DeleteRuleCascade
public static final int DeleteRuleDeny
public static final int DeleteRuleNoAction
This rule is useful in performance tuning. You should however, use this with caution since it can result in dangling references in the object graph.
public static final int DeleteRuleNullify
null
. For example, suppose a
department has a relationship to multiple employees. When
the department is deleted, any references an employee has to the
department are set to null
.
Constructor Detail |
public EOClassDescription()
Method Detail |
public NSArray attributeKeys()
NSArray.EmptyArray
entityName()
,
toOneRelationshipKeys()
,
toManyRelationshipKeys()
public void awakeObjectFromFetch(EOEnterpriseObject object, EOEditingContext editingContext)
object
in editingContext
. The default
implementation simply returns.
object
- the object to be initializededitingContext
- EOEditingContext object that manages a graph of
enterprise objectspublic void awakeObjectFromInsertion(EOEnterpriseObject object, EOEditingContext editingContext)
anEditingContext
.
More specifically, if object
has a relationship, or relationships,
that propagates the object's primary key and if no object yet
exists at the destination of that relationship, subclasses should
create the new object at the destination of the relationship.
This method is used to put default values in the enterprise object.
object
- newly inserted enterprise
objectseditingContext
- EOEditingContext object that manages a graph of
enterprise objects in an applicationpublic static Object classDelegate()
setClassDelegate(Object delegate)
public static EOClassDescription classDescriptionForClass(Class aClass)
classDescription
.
It's generally not safe to use this method directly since
individual EOGenericRecord instances can have different
class descriptions. If a class description for aClass
isn't found,
this method posts a ClassDescriptionNeededForClassNotification
on behalf of the receiver's class, allowing an observer to register
a an EOClassDescription.
aClass
- receiver's class whose description is to be returned
aClass
ClassDescriptionNeededForClassNotification
,
EOEnterpriseObject.classDescription()
public EOClassDescription classDescriptionForDestinationKey(String detailKey)
detailKey
.
For example, the statement:
might return the class description for the Studio class. The default implementation of this method returnsmovie.classDescriptionForDestinationKey(studio)
null
.
detailKey
- identifies the to-one relationship
detailKey
; it may not return anythingpublic static EOClassDescription classDescriptionForEntityName(String entityName)
entityName
.
entityName
- registration key for the EOClassDescription
entityName
public EOClassDescription classDescriptionForKeyPath(String key)
public Class classForAttributeKey(String key)
public NSArray clientAttributeKeys()
public NSArray clientToManyRelationshipKeys()
public NSArray clientToOneRelationshipKeys()
public EOEnterpriseObject createInstanceWithEditingContext(EOEditingContext editingContext, EOGlobalID globalID)
editingContext
with globalID
. In typical usage,
both of the method's arguments are null
. To create the object, the
subclass should pass anEditingContext
itself, and
globalID
to the appropriate constructor. Enterprise Objects Framework
uses this method to create new instances of objects when fetching existing enterprise
objects or inserting new ones in an interface layer EODisplayGroup.
EOClassDescription's implementation of this method returns null
.
editingContext
- an EOEditingContext object manages a graph
of enterprise objects in an application.globalID
- a compact, universal identifier
for a persistent object.
null
public Format defaultFormatterForKey(String key)
key
in the associated model file. Code that creates a user
interface, like an assistant, can use this method to assign formatters to user
interface elements. The default implementation of this method returns null
.
key
- values are assigned to this
null
public Format defaultFormatterForKeyPath(String keyPath)
defaultFormatterForKey
, except this method traverses
keyPath
before returning the formatter for the key at the end of the
path.
keyPath
- the path to traverse
public int deleteRuleForRelationshipKey(String relationshipKey)
relationshipKey
- the given relationship whose destination is
to be treated with the delete rule
DeleteRuleNullify
of the given relationshipEOEnterpriseObject.propagateDeleteWithEditingContext(
EOEditingContext ec)
,
DeleteRuleCascade
,
DeleteRuleDeny
,
DeleteRuleNullify
,
DeleteRuleNoAction
public String displayNameForKey(String key)
key
in the user interface.
By convention, lowercase words are capitalized (for example,
"revenue" becomes "Revenue"), and spaces are inserted into
words with mixed case (for example, "first Name" becomes "First
Name"). This method is useful if a user interface is created
from only a class description, such as with an assistant or a Direct
To Web application.
key
- the key to be displayed
public String entityName()
null
.
attributeKeys()
,
toOneRelationshipKeys()
,
toManyRelationshipKeys()
public EOFetchSpecification fetchSpecificationNamed(String name)
name
.
For example, the EOAccess layer's EOEntityClassDescription returns
the fetch specification in its EOEntity named name
.
The default implementation of this method returns null
.
name
- the name attribute of the object
public void finalize() throws Throwable
Throwable
public static void invalidateClassDescriptionCache()
public String inverseForRelationshipKey(String relationshipKey)
relationshipKey
. 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.
The statement:
returns the string "employees"(such that this employee would appear in employee.valueForKey("department").valueForKey("employees")).employee.inverseForRelationshipKey(department);
relationshipKey
- specifies the relationship to evaluate
null
public boolean ownsDestinationObjectsForRelationshipKey(String relationshipKey)
relationshipKey
should be deleted if they are removed from the
relationship. The alternative is that they would be transferred to the
corresponding relationship of another object. 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't exist outside of an Invoice.
relationshipKey
- specifies the relationship
true
or false
to indicate whether
the objects should be deleted; default implementation returns false
public void propagateDeleteForObject(EOEnterpriseObject obj, EOEditingContext ec)
obj
- object for which the delete operation is to be propagatedec
- an editing contextEOEnterpriseObject
,
deleteRuleForRelationshipKey(String relationshipKey)
public static void registerClassDescription(EOClassDescription description, Class aClass)
description
- the EOClassDescription cacheaClass
- EOClassDescription object is registered for thispublic static void setClassDelegate(Object delegate)
delegate
- the delegate for the EOClassDescription classEOClassDescription.ClassDelegate
,
classDelegate()
public EOClassDescription superClassDescription()
null
.
public NSArray toManyRelationshipKeys()
NSArray.EmptyArray
entityName()
,
toOneRelationshipKeys()
,
attributeKeys()
public NSArray toOneRelationshipKeys()
NSArray.EmptyArray
entityName()
,
attributeKeys()
,
toManyRelationshipKeys()
public String toString()
entityName()
,
attributeKeys()
,
toOneRelationshipKeys()
,
toManyRelationshipKeys()
public String userPresentableDescriptionForObject(EOEnterpriseObject eo)
attributeKeys
and returns each attribute's value, separated by commas.
The default formatter is applied for numbers and dates.
eo
- an EOEnterpriseObject
public void validateObjectForDelete(EOEnterpriseObject object) throws NSValidation.ValidationException
object
- the object to be deleted
NSValidation.ValidationException
- if the delete
operation should not proceed.
NSValidation.ValidationException
public void validateObjectForSave(EOEnterpriseObject object) throws NSValidation.ValidationException
object
- object whose values are to be accepted when it is saved
NSValidation.ValidationException
- if the values are not
acceptable
NSValidation.ValidationException
public Object validateValueForKey(Object value, String key) throws NSValidation.ValidationException
null
if the value is acceptable, or throw an exception containing
a user presentable (localized) error message if not. Implementations
can replace value
by returning a new value.
value
- the value to be validatedkey
- identifies the property of an object
null
if the value is acceptable; throws exception
if unacceptable
NSValidation.ValidationException
- if the value is unacceptable.
NSValidation.ValidationException
EOValidation
|
Last updated Thu Oct 21 15:04:16 PDT 2004. | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |