EOGenericRecord
- Inherits from:
- (com.apple.client.eocontrol) EOCustomObject : Object
(com.apple.yellow.eocontrol) NSObject
- Implements:
- EOEnterpriseObject
- EODeferredFaulting (EOEnterpriseObject)
- EOKeyValueCodingAdditions (EOEnterpriseObject)
- EOKeyValueCoding.KeyBindingCreation (EOEnterpriseObject)
- EORelationshipManipulation (EOEnterpriseObject)
- EOValidation (EOEnterpriseObject)
- EOFaulting (EODeferredFaulting)
- EOKeyValueCoding (EOKeyValueCodingAdditions)
- (com.apple.client.eocontrol only) NSKeyValueCoding (EOKeyValueCoding)
- (com.apple.client.eocontrol only) NSInlineObservable
- Package:
- com.apple.client.eocontrol
- com.apple.yellow.eocontrol
Class Description
EOGenericRecord is a generic enterprise object class that can be used in place of custom classes when you don't need custom behavior. It implements the EOEnterpriseObject interface to provide the basic enterprise object behavior. An EOGenericRecord object has an EOClassDescription that provides metadata about the generic record, including the name of the entity that the generic record represents and the names of the record's attributes and relationships. A generic record stores its properties in a dictionary using its attribute and relationship names as keys.
In the typical case of applications that access a relational database, the access layer's modeling objects are an important part of how generic records map to database rows: If an EOModel doesn't have a custom enterprise object class defined for a particular entity, an EODatabaseChannel using that model creates EOGenericRecords when fetching objects for that entity from the database server. During this process, the EODatabaseChannel also sets each generic record's class description to an EOEntityClassDescription, providing the link to the record's associated modeling objects. (EOModel, EODatabaseChannel, and EOEntityClassDescription are defined in EOAccess.)
Creating an Instance of EOGenericRecord
The best way to create an instance of EOGenericRecord is using the EOClassDescription method createInstanceWithEditingContext as follows:
EOEnterpriseObject newEO; String entityName; // Assume this exists. EOClassDescription description = ClassDescription.classDescriptionForEntityName(entityName); newEO = description.createInstanceWithEditingContext(null, null);
createInstanceWithEditingContext
is
preferable to using the constructor because the same code works if
you later use a custom enterprise object class instead of EOGenericRecord.
You can get an EOClassDescription for an entity name as shown above.
Alternatively, you can get an EOClassDescription for a destination
key of an existing enterprise object as follows:
EOEnterpriseObject newEO; EOEnterpriseObject existingEO; // Assume this exists. String relationshipName; // Assume this exists. EOClassDescription sourceDesc = existingEO.classDescription(); EOClassDescription desc = sourceDesc.classDescriptionForDestinationKey(relationshipName); newEO = desc.createInstanceWithEditingContext(null, null);
The technique in this example is useful for inserting a new destination object into an existing enterprise object-for creating a new Movie object to add to a Studio's array of Movies, for example.
Constructors
EOGenericRecord
public
EOGenericRecord
(
EOEditingContext anEditingContext,
EOClassDescription aClassDescription,
EOGlobalID globalID)
null
for anEditingContext and globalID,
because the arguments are optional: EOGenericRecord's implementation
does nothing with them. Throws an exception if aClassDescription is null
.You shouldn't use these constructors to create new EOGenericRecords. Rather, use EOClassDescription's createInstanceWithEditingContext method. See the class description for more information.
Instance Methods
storedValueForKey
public abstract Object
storedValueForKey
(String key)
See Also: storedValueForKey ( EOKeyValueCoding)
takeStoredValueForKey
public abstract void
takeStoredValueForKey
(
Object value,
String key)
See Also: takeStoredValueForKey ( EOKeyValueCoding)
takeValueForKey
public void
takeValueForKey
(
Object value,
String key)
valueForKey
public Object
valueForKey
(String key)