|
WebObjects 5.2 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.webobjects.eocontrol.EODataSource | +--com.webobjects.eoaccess.EODatabaseDataSource
EODatabaseDataSource is a concrete subclass of EODataSource, defined in EOControl. EODatabaseDataSource fetches objects based on an EOModel, using an EODatabaseContext that services the data source's EOEditingContext. An EODatabaseDataSource can be set up to fetch all objects for its root entity or to fetch objects matching a particular EOFetchSpecification, and to further filter its fetching with an auxiliary qualifier.
EODatabaseDataSource implements all the functionality defined by EODataSource. In addition to fetching objects, it can insert and delete them (provided the entity isn't read-only). As with other data sources, EODatabaseDataSource can also provide a detail data source.
EODataSource
,
EODetailDataSource
, Serialized FormInner classes inherited from class com.webobjects.eocontrol.EOKeyValueArchiving |
EOKeyValueArchiving.Awaking, EOKeyValueArchiving.FinishInitialization, EOKeyValueArchiving.Support |
Inner classes inherited from class com.webobjects.foundation.NSCoding |
NSCoding.Support |
Constructor Summary | |
EODatabaseDataSource(EOEditingContext anEditingContext,
String anEntityName)
Constructs a new EODatabaseDataSource to fetch all objects for the EOEntity specified by anEntityName into
anEditingContext . |
|
EODatabaseDataSource(EOEditingContext anEditingContext,
String anEntityName,
String fetchSpecificationName)
Constructs a new EODatabaseDataSource to fetch objects into anEditingContext for the EOEntity specified
by anEntityName using the fetch specification
fetchSpecificationName . |
Method Summary | |
EOQualifier |
auxiliaryQualifier()
Returns the auxiliary EOQualifier used to further restrict the fetch criteria defined by the receiver's EOFetchSpecification. |
void |
awakeFromKeyValueUnarchiver(EOKeyValueUnarchiver unarchiver)
Finishes initialization of a data source unarchived from EOKeyValueArchiving. |
void |
awakeFromNib()
Finishes initialization of a data source from a nib file. |
EOClassDescription |
classDescriptionForObjects()
Returns the class description for the root entity of the receiver. |
Class |
classForCoder()
Conformance to NSCoding. |
Object |
createObject()
Creates a new object, inserts it in the receiver's collection of objects if appropriate, and returns the object. |
EODatabaseContext |
databaseContext()
Returns the EODatabaseContext that is used to access the external database. |
EODataSource |
dataSourceQualifiedByKey(String key)
Returns a detail data source that provides the destination objects of the relationship named by key . |
static Object |
decodeObject(NSCoder coder)
Decodes and returns an EODatabaseDataSource using coder . |
static Object |
decodeWithKeyValueUnarchiver(EOKeyValueUnarchiver unarchiver)
Conformance to EOKeyValueArchiving. |
void |
deleteObject(Object object)
Deletes object from the data source. |
EOEditingContext |
editingContext()
Returns the EOEditingContext into which objects from this data source are fetched. |
void |
encodeWithCoder(NSCoder coder)
Conformance to NSCoding. |
void |
encodeWithKeyValueArchiver(EOKeyValueArchiver archiver)
Conformance to EOKeyValueArchiving. |
EOEntity |
entity()
Returns the root entity of the receiver. |
NSArray |
fetchObjects()
Fetches and returns an array of objects using the fetch specification and editing context associated with this datasource. |
EOFetchSpecification |
fetchSpecification()
Returns the receiver's EOFetchSpecification or null
if no fetch specification is set. |
EOFetchSpecification |
fetchSpecificationForFetch()
Returns a copy of the effective fetch specification, which is the union of the primary fetch specification and the auxiliary qualifier. |
String |
fetchSpecificationName()
Returns the name of the receiver's fetch specification or null if the data source is not using a
named fetch specification. |
void |
insertObject(Object object)
The default implementation does nothing. |
boolean |
isFetchEnabled()
Returns true if fetching is enabled, false
otherwise. |
NSArray |
qualifierBindingKeys()
Returns an array of strings which is a union of the binding keys from the fetch specification's qualifier and the data source's auxiliary qualifier, or NSArray.EmptyArray if there are no bindings. |
NSDictionary |
qualifierBindings()
Returns a dictionary of bindings to be used for variable replacement on the fetch specification's qualifier and the auxiliary qualifier before the fetch is executed. |
void |
qualifyWithRelationshipKey(String key,
Object sourceObject)
Sets the primary qualifier for the fetch specification for the relationship named key owned by the enterprise
object sourceObject . |
void |
setAuxiliaryQualifier(EOQualifier newQualifier)
Sets the auxiliary qualifier to newQualifier . |
void |
setEditingContext(EOEditingContext editingContext)
Used internally. |
void |
setFetchEnabled(boolean yn)
Controls whether objects can be fetched by the receiver. |
void |
setFetchSpecification(EOFetchSpecification fetchSpec)
Sets the fetch specification used when supplying objects to fetchSpec . |
void |
setFetchSpecificationByName(String fetchSpecificationName)
Retrieves the fetch specification identified by fetchSpecificationName from the root EOEntity for
the receiver and sets it as the receiver's fetch specification. |
void |
setParentDataSourceRelationshipKey(EODataSource parent,
String key)
Called from Interface Builder to reset the parent entity. |
void |
setQualifierBindings(NSDictionary bindings)
Sets a dictionary of bindings to be used for variable replacement on the fetch specification's qualifier and the auxiliary qualifier before the fetch is executed. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public EODatabaseDataSource(EOEditingContext anEditingContext, String anEntityName, String fetchSpecificationName)
anEditingContext
for the EOEntity specified
by anEntityName
using the fetch specification
fetchSpecificationName
. Finds the EOObjectStoreCoordinator
for anEditingContext
and searches for a channel
that services the model of the entity. If one exists,
the EODatabaseDataSource uses it. Otherwise, a new one is created
for this EODatabaseDataSource.
fetchSpecificationName
is used to find the fetch
specification in the entity. If fetchSpecificationName
is null
, a new fetch specification is instantiated that
will fetch all objects of the entity.
anEditingContext
- The EOEditingContext into which to
fetch objects.anEntityName
- The EOEntity for this data source.fetchSpecificationName
- The criteria to select and order a
group of database records, or
null
.public EODatabaseDataSource(EOEditingContext anEditingContext, String anEntityName)
anEntityName
into
anEditingContext
. Finds the EOObjectStoreCoordinator
for anEditingContext
and searches for a channel
that services the model of the entity. If one exists,
the EODatabaseDataSource uses it. Otherwise, a new one is created
for this EODatabaseDataSource.anEditingContext
- The EOEditingContext into which to
fetch objects.anEntityName
- The EOEntity for this data source.Method Detail |
public EOQualifier auxiliaryQualifier()
public void awakeFromKeyValueUnarchiver(EOKeyValueUnarchiver unarchiver)
awakeFromKeyValueUnarchiver
in interface EOKeyValueArchiving.Awaking
unarchiver
- The EOKeyValueUnarchiver that decoded the
receiver.public void awakeFromNib()
public EOClassDescription classDescriptionForObjects()
classDescriptionForObjects
in class EODataSource
public Class classForCoder()
classForCoder
in interface NSCoding
public Object createObject()
EODataSource
null
if the receiver can't create the object or can't insert it.
You should invoke insertObject
after this method to actually add
the new object to the receiver.
As a convenience, EODataSource's implementation sends the receiver's
EOClassDescription a createInstanceWithEditingContext
message to create the object. If this succeeds and the receiver has an
EOEditingContext, it sends the EOEditingContext an
insertObject
message to register the new object with the
EOEditingContext (note that this does not insert the object into
the EODataSource). Subclasses that don't use
EOClassDescriptions or EOEditingContexts should
override this method without invoking the superclass's implementation.
createObject
in class EODataSource
com.webobjects.eocontrol.EODataSource
null
if the receiver can't create the object or can't insert it,
otherwise returns the objectEODataSource.insertObject(Object object)
,
EOClassDescription.createInstanceWithEditingContext(
EOEditingContext editingContext, EOGlobalID globalID)
,
EODataSource.classDescriptionForObjects()
,
EODataSource.editingContext()
public EODataSource dataSourceQualifiedByKey(String key)
key
. The returned detail
data source can be qualified by using
qualifyWithRelationshipKey
to set a specific master
object or to change the relationship key.dataSourceQualifiedByKey
in class EODataSource
key
- The name of the relationship.key
.public EODatabaseContext databaseContext()
public static Object decodeObject(NSCoder coder)
coder
. For NSCoding conformance.coder
- The NSCoder object to decode the data source.public static Object decodeWithKeyValueUnarchiver(EOKeyValueUnarchiver unarchiver)
unarchiver
- The EOKeyValueArchiver object with which to encode
the receiver.public void deleteObject(Object object)
object
from the data source. If the receiver
registers undos for the deletion, the receiver may receive a redundant
insertObject
call.deleteObject
in class EODataSource
object
- An Enterprise Object to delete from the data source.public EOEditingContext editingContext()
editingContext
in class EODataSource
public void encodeWithCoder(NSCoder coder)
encodeWithCoder
in interface NSCoding
coder
- An NSCoder object to encode the receiver.public void encodeWithKeyValueArchiver(EOKeyValueArchiver archiver)
encodeWithKeyValueArchiver
in interface EOKeyValueArchiving
archiver
- The EOKeyValueArchiver object with which to encode
the receiver.public EOEntity entity()
public NSArray fetchObjects()
null
if the receiver's fetch specification is
null
.fetchObjects
in class EODataSource
null
.isFetchEnabled()
,
setFetchEnabled(boolean flag)
public EOFetchSpecification fetchSpecification()
null
if no fetch specification is set. The fetch specification for a
data source can be set with either setFetchSpecification
or setFetchSpecificationByName
.null
.setFetchSpecification(EOFetchSpecification fetchSpec)
,
setFetchSpecificationByName(String fetchSpecificationName)
public EOFetchSpecification fetchSpecificationForFetch()
fetchObjects
. To permanently modify fetching
behavior, use setFetchSpecification
and/or
setAuxiliaryQualifier
to change the receiver's fetch
specification and auxiliary qualifier.null
.fetchObjects()
,
setFetchSpecification(EOFetchSpecification fetchSpec)
,
setAuxiliaryQualifier(EOQualifier aQualifier)
public String fetchSpecificationName()
null
if the data source is not using a
named fetch specification.setFetchSpecification(EOFetchSpecification fetchSpec)
,
setFetchSpecificationByName(String fetchSpecificationName)
public void insertObject(Object object)
insertObject
in class EODataSource
object
- An Enterprise Object to insert in the current editing
context.public boolean isFetchEnabled()
true
if fetching is enabled, false
otherwise. Fetching is typically disabled in a master-peer
configuration whenno object is selected in the master.true
if fetching is enabled, false
otherwise.setFetchEnabled(boolean yn)
public NSArray qualifierBindingKeys()
public NSDictionary qualifierBindings()
public void qualifyWithRelationshipKey(String key, Object sourceObject)
key
owned by the enterprise
object sourceObject
. Throws an exception if:
sourceObject
sourceObject
has no
relationship named key
key
qualifyWithRelationshipKey
in class EODataSource
key
- The name of the relationship to qualify.sourceObject
- The owner of the relationship named
key
.
this must be an EOEnterpriseObjectIllegalStateException
- unable to find source
entity or relationship or unable to build
the qualifier.EODataSource.dataSourceQualifiedByKey(String key)
public void setAuxiliaryQualifier(EOQualifier newQualifier)
newQualifier
.
The auxiliary qualifier usually adds restricting conditions
to the primary qualifier and is useful for narrowing the scope
of a data source without altering its primary qualifier. This is
especially useful for setting a qualifier on a qualified peer
data source, since a peer's primary qualifier specifies
the matching criteria for the relationship for which it fetches.newQualifier
- The new auxiliary EOQualifier.fetchSpecificationForFetch()
,
fetchSpecification()
public void setEditingContext(EOEditingContext editingContext)
public void setFetchEnabled(boolean yn)
yn
is true
, the method
fetchObjects
fetches objects from the external
data source when invoked. If false
,
fetchObjects
does not perform a fetch and returns
an empty array.
Fetching is typically disabled when the data source is acting as
a peer in a master-peer configuration and the master does not have
an object selected. For example, EODatabaseDataSource's
implementation of qualifyWithRelationshipKey
invokes
this method to enable or disable fetching based on whether a master
object is provided.
yn
- Boolean flag to determine whether fetching is enabled.isFetchEnabled()
,
qualifyWithRelationshipKey(String key,
Object sourceObject)
public void setFetchSpecification(EOFetchSpecification fetchSpec)
fetchSpec
. The primary EOQualifier is conjoined with
the auxiliary EOQualifier when objects are fetched. This method
also sets the fetchSpecificationName
to
null
. To use a named fetch specification from an entity,
invoke setFetchSpecificationByName
.fetchSpec
- The criteria to select and order a group of
database records.setAuxiliaryQualifier(EOQualifier aQualifier)
,
fetchSpecificationForFetch()
,
(String fetchSpecificationName)
,
EOFetchSpecification
public void setFetchSpecificationByName(String fetchSpecificationName)
fetchSpecificationName
from the root EOEntity for
the receiver and sets it as the receiver's fetch specification.
Sets the receiver's fetch specification name to
fetchSpecificationName
. Throws an exception if
unable to retrieve the named fetch specification from the root
entity.fetchSpecificationName
- The name of the fetch specification
to set as the receiver's fetch
specification, obtained from the root
entity.EOObjectNotAvailableException
- if the
root entity does not have a fetch
specification named
fetchSpecificationName
.fetchSpecification()
,
fetchSpecificationName()
public void setParentDataSourceRelationshipKey(EODataSource parent, String key)
parent
- The master of the detail data source.key
- The name of the relationship.qualifyWithRelationshipKey(String key,
Object sourceObject)
public void setQualifierBindings(NSDictionary bindings)
bindings
- NSDictionary of qualifier bindings.qualifierBindings()
|
Last updated Fri Feb 21 13:15:00 PST 2003. | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |