net.wotonomy.control
Class EOClassDescription

java.lang.Object
  extended by net.wotonomy.control.EOClassDescription
Direct Known Subclasses:
EOEntityClassDescription

public class EOClassDescription
extends java.lang.Object

EOClassDescription provides meta-information about a class and is used to customize certain behaviors within wotonomy and specifically within editing contexts and object stores.

The default implementation works for most well-formed java beans, but you will want to create your own subclass most typically to customize the toOne and toMany relationships for your class to ensure that an entire graph of objects is not persisted in order to perist a single object.

The easiest way to register your subclass is to create it in the same package as the class it describes but with a "ClassDesc" suffix. For example, "my.package.MyEntity" would be described by "my.package.MyEntityClassDesc".

Note that while the interface is the same, the implementation of this class differs substantially from the specification in order to be more useful for java classes.

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

Field Summary
static java.lang.String ClassDescriptionNeededForClassNotification
          Notification fired when a class description has been requested for a class.
static java.lang.String ClassDescriptionNeededForEntityNameNotification
          Notification fired when a class description has been requested for an entity name.
static int DeleteRuleCascade
          A delete rule specifying that object(s) referenced by this object should also be deleted when this object is deleted.
static int DeleteRuleDeny
          A delete rule specicying that this object should not be allowed to be deleted if it references any object(s).
static int DeleteRuleNoAction
          A delete rule specifying that no action be taken when this object is deleted.
static int DeleteRuleNullify
          A delete rule specifying that object(s) that reference this object should have those references set to null when this object is deleted.
protected  java.lang.Class theClass
           
 
Constructor Summary
  EOClassDescription()
           
protected EOClassDescription(java.lang.Class aClass)
          Constructor may only be called by subclasses.
 
Method Summary
 net.wotonomy.foundation.NSArray attributeKeys()
          Returns a List of all the attributes for this class.
 void awakeObjectFromFetch(java.lang.Object object, EOEditingContext anEditingContext)
          This method is called when the specified object has been fetched into the specified editing context.
 void awakeObjectFromInsertion(java.lang.Object object, EOEditingContext anEditingContext)
          This method is called when the specified object has been inserted into the specified editing context.
static EOClassDescription classDescriptionForClass(java.lang.Class aClass)
          Returns the class description that corresponds to the specified class.
 EOClassDescription classDescriptionForDestinationKey(java.lang.String detailKey)
          Returns the class decription for the object referenced by the specified relationship key, or null if the class description cannot be determined for that key.
static EOClassDescription classDescriptionForEntityName(java.lang.String aName)
          Returns the class description that corresponds to the specified entity name.
 java.lang.Object createInstanceWithEditingContext(EOEditingContext anEditingContext, EOGlobalID globalID)
          Creates a new instance of the class represented by this class description, registering it with the specified editing context and global id.
 int deleteRuleForRelationshipKey(java.lang.String relationshipKey)
          Returns the delete rule to be used for the specified relationship key.
 java.lang.String displayNameForKey(java.lang.String key)
          Returns a human-readable title for the specified key.
 java.lang.String entityName()
          Returns a human-readable title for the class of objects that this class description represents.
 EOFetchSpecification fetchSpecificationNamed(java.lang.String aString)
          Returns the fetch specification associated with this class description that corresponds to the specified name, or null if not found.
 java.lang.Class getDescribedClass()
          Returns the Java Class that this description describes.
static void invalidateClassDescriptionCache()
          Clears all cached class descriptions so that new requests for class descriptions will be re-loaded on-demand.
 java.lang.String inverseForRelationshipKey(java.lang.String relationshipKey)
          Returns the relationship key by which the object at the other end of the specified relationship key refers to this object, or null if not found.
 boolean ownsDestinationObjectsForRelationshipKey(java.lang.String relationshipKey)
           
 void propagateDeleteForObject(java.lang.Object object, EOEditingContext anEditingContext)
          Called when this object has been deleted from the specified editing context.
static void registerClassDescription(EOClassDescription description, java.lang.Class aClass)
          Registers the specified class descriptiong for the specified class.
 net.wotonomy.foundation.NSArray toManyRelationshipKeys()
          Returns a List of the "to many" relationships for this class.
 net.wotonomy.foundation.NSArray toOneRelationshipKeys()
          Returns a List of the "to one" relationships for this class.
 java.lang.String userPresentableDescriptionForObject(java.lang.Object anObject)
          Returns a human-readable description of the specified object that should not exceed 60 characters.
 void validateObjectForDelete(java.lang.Object object)
          Verifies that the specified object may be deleted.
 void validateObjectForSave(java.lang.Object object)
          Verifies that the specified object may be saved.
 java.lang.Object validateValueForKey(java.lang.Object value, java.lang.String key)
          Validates the specified value for the specified key on this this class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DeleteRuleNullify

public static final int DeleteRuleNullify
A delete rule specifying that object(s) that reference this object should have those references set to null when this object is deleted.

See Also:
Constant Field Values

DeleteRuleCascade

public static final int DeleteRuleCascade
A delete rule specifying that object(s) referenced by this object should also be deleted when this object is deleted.

See Also:
Constant Field Values

DeleteRuleDeny

public static final int DeleteRuleDeny
A delete rule specicying that this object should not be allowed to be deleted if it references any object(s).

See Also:
Constant Field Values

DeleteRuleNoAction

public static final int DeleteRuleNoAction
A delete rule specifying that no action be taken when this object is deleted. This is the default.

See Also:
Constant Field Values

ClassDescriptionNeededForClassNotification

public static final java.lang.String ClassDescriptionNeededForClassNotification
Notification fired when a class description has been requested for a class. Observers should watch for this notification and call registerClassDescription so that class descriptions can be loaded on-demand. The notification's object is the requested class and the user info dictionary is null.

See Also:
Constant Field Values

ClassDescriptionNeededForEntityNameNotification

public static final java.lang.String ClassDescriptionNeededForEntityNameNotification
Notification fired when a class description has been requested for an entity name. Observers should watch for this notification and call registerClassDescription so that class descriptions can be loaded on-demand. The notification's object is the requested name and the user info dictionary is null.

See Also:
Constant Field Values

theClass

protected java.lang.Class theClass
Constructor Detail

EOClassDescription

public EOClassDescription()

EOClassDescription

protected EOClassDescription(java.lang.Class aClass)
Constructor may only be called by subclasses.

Method Detail

classDescriptionForClass

public static EOClassDescription classDescriptionForClass(java.lang.Class aClass)
Returns the class description that corresponds to the specified class. If the class description has not already been loaded, a ClassDescriptionNeededForClassNotification is posted. If the class description is still not found, the class' loader is consulted for a class in the same package and named the same as the specified class but appended with "ClassDesc", e.g. "EmployeeObjectClassDesc". If the class description is still not found, a class description is returned that uses java bean introspection to provide reasonable values.


classDescriptionForEntityName

public static EOClassDescription classDescriptionForEntityName(java.lang.String aName)
Returns the class description that corresponds to the specified entity name. If the class description has not already been loaded, a ClassDescriptionNeededForEntityNameNotification is posted. Returns null if no class description can be found for the entity name.


invalidateClassDescriptionCache

public static void invalidateClassDescriptionCache()
Clears all cached class descriptions so that new requests for class descriptions will be re-loaded on-demand.


registerClassDescription

public static void registerClassDescription(EOClassDescription description,
                                            java.lang.Class aClass)
Registers the specified class descriptiong for the specified class. Nulls are not allowed - to clear the cache call invalidateClassDescriptionCache().


attributeKeys

public net.wotonomy.foundation.NSArray attributeKeys()
Returns a List of all the attributes for this class. This implementation reflects on the java class to produce a list of attributes, and then removes those keys that are returned by toOneRelationshipKeys and toManyRelationhipKeys.


awakeObjectFromFetch

public void awakeObjectFromFetch(java.lang.Object object,
                                 EOEditingContext anEditingContext)
This method is called when the specified object has been fetched into the specified editing context. Fetch means an object was fetched using a fetch specification - it is not the same thing as an insertion. This implementation does nothing.


awakeObjectFromInsertion

public void awakeObjectFromInsertion(java.lang.Object object,
                                     EOEditingContext anEditingContext)
This method is called when the specified object has been inserted into the specified editing context. Insertion means an object was inserted by a display group - it does not mean the same thing as a fetch. This implementation does nothing.


classDescriptionForDestinationKey

public EOClassDescription classDescriptionForDestinationKey(java.lang.String detailKey)
Returns the class decription for the object referenced by the specified relationship key, or null if the class description cannot be determined for that key. This implementation returns null.


createInstanceWithEditingContext

public java.lang.Object createInstanceWithEditingContext(EOEditingContext anEditingContext,
                                                         EOGlobalID globalID)
Creates a new instance of the class represented by this class description, registering it with the specified editing context and global id. The class description may not keep references to the newly created object. The editing context and/or the id may be null. This implementation constructs a new instance of the class and registers it with the specified editing context. If the global id is specified, the object will be populated with the appropriate data, otherwise the object will be treated as a newly inserted object. If no editing context is specified, the global id is ignored and the new instance of the class is returned.


deleteRuleForRelationshipKey

public int deleteRuleForRelationshipKey(java.lang.String relationshipKey)
Returns the delete rule to be used for the specified relationship key. This implementation returns DeleteRuleNoAction.


displayNameForKey

public java.lang.String displayNameForKey(java.lang.String key)
Returns a human-readable title for the specified key. For example, displayNameForKey( "firstName" ) might return "First Name". This implementation attempts to construct such a string from the key, uppercasing the first character and inserting spaces before subsequent uppercase characters.


entityName

public java.lang.String entityName()
Returns a human-readable title for the class of objects that this class description represents. For example, class CustomerObject might return "Customer". This implementation returns the class name.


fetchSpecificationNamed

public EOFetchSpecification fetchSpecificationNamed(java.lang.String aString)
Returns the fetch specification associated with this class description that corresponds to the specified name, or null if not found. This implementation returns null.


inverseForRelationshipKey

public java.lang.String inverseForRelationshipKey(java.lang.String relationshipKey)
Returns the relationship key by which the object at the other end of the specified relationship key refers to this object, or null if not found. This implementation returns null.


ownsDestinationObjectsForRelationshipKey

public boolean ownsDestinationObjectsForRelationshipKey(java.lang.String relationshipKey)

propagateDeleteForObject

public void propagateDeleteForObject(java.lang.Object object,
                                     EOEditingContext anEditingContext)
Called when this object has been deleted from the specified editing context. The delete rules for this object's relationships should be executed.


toManyRelationshipKeys

public net.wotonomy.foundation.NSArray toManyRelationshipKeys()
Returns a List of the "to many" relationships for this class. This implementation returns an empty list.


toOneRelationshipKeys

public net.wotonomy.foundation.NSArray toOneRelationshipKeys()
Returns a List of the "to one" relationships for this class. This implementation returns an empty list.


userPresentableDescriptionForObject

public java.lang.String userPresentableDescriptionForObject(java.lang.Object anObject)
Returns a human-readable description of the specified object that should not exceed 60 characters. This implementation returns anObject.toString().


validateObjectForDelete

public void validateObjectForDelete(java.lang.Object object)
Verifies that the specified object may be deleted. Throws an exception with a user-readable error message if the delete operation should not be allowed. This implementation does nothing.


validateObjectForSave

public void validateObjectForSave(java.lang.Object object)
Verifies that the specified object may be saved. Throws an exception with a user-readable error message if the save operation should not be allowed. This implementation does nothing.


validateValueForKey

public java.lang.Object validateValueForKey(java.lang.Object value,
                                            java.lang.String key)
Validates the specified value for the specified key on this this class. Returns null if the value is acceptable, or returns an object that should be used in place of the specified object, or throws an exception with a user-readable error message if no acceptable value can be determined. This implementation returns null.


getDescribedClass

public java.lang.Class getDescribedClass()
Returns the Java Class that this description describes. NOTE: This method is not in the specification.



Copyright © 2006 null. All Rights Reserved.