|
WebObjects 5.2 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.webobjects.eoaccess.EOUtilities
This class is a collection of convenience methods intended to make common operations with EOF easier. It consists entirely of static methods: you never instantiate an EOUtilities object.
Most methods require an EOEditingContext into which the objects should be fetched. This editing context is passed as the first argument to those methods.
Passing ofnull
arguments will result in runtime exceptions,
unless otherwise noted.
Inner Class Summary | |
static class |
EOUtilities.MoreThanOneException
This exception is thrown from the methods in EOUtilities, indicating that multiple objects were found in a search that expected exactly one object as result. |
Constructor Summary | |
EOUtilities()
|
Method Summary | |
static void |
connectWithModelNamed(EOEditingContext ec,
String name,
NSDictionary overrides)
Connects to the database using the connection information in the specified model augmented by the overrides dictionary. |
static EOEnterpriseObject |
createAndInsertInstance(EOEditingContext ec,
String entityName)
Creates a new Enterprise Object for the specified entity, inserts it into ec , and returns the new object. |
static EODatabaseContext |
databaseContextForModelNamed(EOEditingContext ec,
String name)
Returns the database context used to service the specified model. |
static NSDictionary |
destinationKeyForSourceObject(EOEditingContext ec,
EOEnterpriseObject object,
String name)
Returns the foreign key for the rows at the destination of the specified relationship. |
static EOEntity |
entityForClass(EOEditingContext ec,
Class theClass)
Returns the entity associated with the specified class. |
static EOEntity |
entityForObject(EOEditingContext ec,
EOEnterpriseObject obj)
Returns the entity associated with the provided Enterprise Object. |
static EOEntity |
entityNamed(EOEditingContext ec,
String name)
Returns the entity with the specified name. |
static NSDictionary |
executeStoredProcedureNamed(EOEditingContext ec,
String name,
NSDictionary args)
Executes the specified stored procedure with the provided arguments. |
static EOEnterpriseObject |
faultWithPrimaryKey(EOEditingContext ec,
String entityName,
NSDictionary pkDict)
Returns the Enterprise Object identified by the specified primary key dictionary. |
static EOEnterpriseObject |
faultWithPrimaryKeyValue(EOEditingContext ec,
String entityName,
Object value)
Fetches the Enterprise Object identified by the specified primary key value. |
static EOEnterpriseObject |
localInstanceOfObject(EOEditingContext ec,
EOEnterpriseObject object)
Translates the specified Enterprise Object from another editing context to the specified one. |
static NSArray |
localInstancesOfObjects(EOEditingContext ec,
NSArray objects)
Translates the specified Enterprise Objects from another editing context to the specified one. |
static EOModelGroup |
modelGroup(EOEditingContext ec)
Returns the model group associated with the editing context's root object store, an EOObjectStoreCoordinator. |
static EOEnterpriseObject |
objectFromRawRow(EOEditingContext ec,
String name,
NSDictionary row)
Fetches the object corresponding to the specified raw row (using faultForRawRow ). |
static EOEnterpriseObject |
objectMatchingKeyAndValue(EOEditingContext ec,
String name,
String key,
Object value)
Creates an EOKeyValueQualifier with the specified key and value and returns the matching Enterprise Object. |
static EOEnterpriseObject |
objectMatchingValues(EOEditingContext ec,
String name,
NSDictionary values)
Creates EOKeyValueQualifiers for each key-value pair in the specified dictionary, ANDs these qualifiers together into an EOAndQualifier, and returns the matching Enterprise Object. |
static NSArray |
objectsForEntityNamed(EOEditingContext ec,
String name)
Fetches the Enterprise Objects associated with the specified entity. |
static NSArray |
objectsMatchingKeyAndValue(EOEditingContext ec,
String name,
String key,
Object value)
Creates an EOKeyValueQualifier with the specified key and value and returns matching Enterprise Objects. |
static NSArray |
objectsMatchingValues(EOEditingContext ec,
String name,
NSDictionary values)
Creates EOKeyValueQualifiers for each key-value pair in the specified dictionary, ANDs these qualifiers together into an EOAndQualifier, and returns matching Enterprise Objects. |
static NSArray |
objectsOfClass(EOEditingContext ec,
Class aClass)
Fetches the Enterprise Objects associated with the specified class. |
static NSArray |
objectsWithFetchSpecificationAndBindings(EOEditingContext ec,
String entityName,
String fetchSpecName,
NSDictionary bindings)
Fetches the Enterprise Objects retrieved with the specified fetch specification and bindings. |
static NSArray |
objectsWithQualifierFormat(EOEditingContext ec,
String name,
String format,
NSArray args)
Creates a qualifier with the provided format string and ordered arguments, and returns matching Enterprise Objects. |
static EOEnterpriseObject |
objectWithFetchSpecificationAndBindings(EOEditingContext ec,
String entityName,
String fetchSpecName,
NSDictionary bindings)
Fetches the Enterprise Object retrieved with the specified fetch specification and bindings. |
static EOEnterpriseObject |
objectWithPrimaryKey(EOEditingContext ec,
String entityName,
NSDictionary pkDict)
Fetches the Enterprise Object identified by the specified primary key dictionary. |
static EOEnterpriseObject |
objectWithPrimaryKeyValue(EOEditingContext ec,
String entityName,
Object value)
Fetches the Enterprise Object identified by the specified primary key value. |
static EOEnterpriseObject |
objectWithQualifierFormat(EOEditingContext ec,
String name,
String format,
NSArray args)
Creates a qualifier with the provided format string and arguments, and returns the matching Enterprise Object. |
static NSDictionary |
primaryKeyForObject(EOEditingContext ec,
EOEnterpriseObject object)
Returns the primary key dictionary for the specified Enterprise Object. |
static EOQualifier |
qualifierForEnterpriseObject(EOEditingContext ec,
EOEnterpriseObject object)
Returns an EOQualifier for the specified Enterprise Object. |
static NSArray |
rawRowsForSQL(EOEditingContext ec,
String name,
String sqlString)
Evaluates the specified SQL and returns the resulting raw rows. |
static NSArray |
rawRowsForStoredProcedureNamed(EOEditingContext ec,
String name,
NSDictionary args)
Executes the specified stored procedure with the provided arguments and returns the resulting raw rows. |
static NSArray |
rawRowsMatchingKeyAndValue(EOEditingContext ec,
String name,
String key,
Object value)
Creates an EOKeyValueQualifier with the specified key and value and returns matching raw rows. |
static NSArray |
rawRowsMatchingValues(EOEditingContext ec,
String name,
NSDictionary values)
Creates EOKeyValueQualifiers for each key-value pair in the specified dictionary, ANDs these qualifiers together into an EOAndQualifier, and returns matching raw rows. |
static NSArray |
rawRowsWithQualifierFormat(EOEditingContext ec,
String name,
String format,
NSArray args)
Creates a qualifier for the specified entity and with the specified qualifier format and returns matching raw row dictionaries. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public EOUtilities()
Method Detail |
public static void connectWithModelNamed(EOEditingContext ec, String name, NSDictionary overrides)
overrides
dictionary. This method
facilitates per-session database logins in WebObjects applications.
Typically, you will put a login name and password in the overrides
dictionary and otherwise use the values in the model's connection
dictionary.ec
- the EOEditingContext to be used to connectname
- the model nameoverrides
- an NSDictionary that overrides the model's connection dictionaryEOObjectNotAvailableException
- if the
connection attempt failedpublic static EOEnterpriseObject createAndInsertInstance(EOEditingContext ec, String entityName)
ec
, and returns the new object.ec
- an EOEditingContextentityName
- the name of entitypublic static EODatabaseContext databaseContextForModelNamed(EOEditingContext ec, String name)
ec
- the EOEditingContextname
- the name of modelEOObjectNotAvailableException
- if the model
name
is not registered with the
EOEditingContext ec
public static NSDictionary destinationKeyForSourceObject(EOEditingContext ec, EOEnterpriseObject object, String name)
Department
and Employee
with a relationship
called department
joining Department.ID
and
Employee.deptID
, invoking this method on a Department
object with ID
equal to 5 returns a dictionary with a
value of 5 for the deptID
key.ec
- the EOEditingContext to be queriedobject
- source EOEnterpriseObjectname
- name of the relationshipEOObjectNotAvailableException
- if ec
doesn't have information that the entity
object
has a relationship called
name
primaryKeyForObject(com.webobjects.eocontrol.EOEditingContext, com.webobjects.eocontrol.EOEnterpriseObject)
public static EOEntity entityForClass(EOEditingContext ec, Class theClass)
ec
- the EOEditingContext to be queriedtheClass
- a Java ClassEOObjectNotAvailableException
- if there is no
matching objectEOUtilities.MoreThanOneException
- if there are
more than one matching objectsentityForObject(com.webobjects.eocontrol.EOEditingContext, com.webobjects.eocontrol.EOEnterpriseObject)
,
entityNamed(com.webobjects.eocontrol.EOEditingContext, java.lang.String)
,
objectsOfClass(com.webobjects.eocontrol.EOEditingContext, java.lang.Class)
public static EOEntity entityForObject(EOEditingContext ec, EOEnterpriseObject obj)
ec
- the EOEditingContext to be queriedobj
- an EOEnterpriseObjectIllegalArgumentException
- if the class
description of obj
as returned by
EOEnterpriseObject.classDescription
is
not an instance of type EOEntityClassDescription
entityForClass(com.webobjects.eocontrol.EOEditingContext, java.lang.Class)
,
entityNamed(com.webobjects.eocontrol.EOEditingContext, java.lang.String)
,
EOEnterpriseObject.classDescription()
,
EOEntityClassDescription
public static EOEntity entityNamed(EOEditingContext ec, String name)
ec
- the EOEditingContext to be queriedname
- the name of the entityEOObjectNotAvailableException
- if no entity
with that name
existsentityForClass(com.webobjects.eocontrol.EOEditingContext, java.lang.Class)
,
entityForObject(com.webobjects.eocontrol.EOEditingContext, com.webobjects.eocontrol.EOEnterpriseObject)
public static NSDictionary executeStoredProcedureNamed(EOEditingContext ec, String name, NSDictionary args)
ec
- an EOEditingContextname
- the name of the stored procedure to callargs
- an NSDictionary of arguments (values keyed by argument name)rawRowsForStoredProcedureNamed(com.webobjects.eocontrol.EOEditingContext, java.lang.String, com.webobjects.foundation.NSDictionary)
public static EOEnterpriseObject faultWithPrimaryKey(EOEditingContext ec, String entityName, NSDictionary pkDict)
ec
- the EOEditingContext to used to resolve the queryentityName
- pkDict
- public static EOEnterpriseObject faultWithPrimaryKeyValue(EOEditingContext ec, String entityName, Object value)
ec
- an EOEditingContextname
- value
- java.lang.IllegalArgumentException
- if the primary key is not formed by exactly one attributepublic static EOEnterpriseObject localInstanceOfObject(EOEditingContext ec, EOEnterpriseObject object)
ec
- the desired EOEditingContextobject
- an Enterprise Object in another EOEditingContextec
, or null
if the object parameter is null
IllegalArgumentException
- if
object
is not associated with an EOEditingContextlocalInstancesOfObjects(com.webobjects.eocontrol.EOEditingContext, com.webobjects.foundation.NSArray)
public static NSArray localInstancesOfObjects(EOEditingContext ec, NSArray objects)
ec
- the desired EOEditingContextobjects
- an NSArray of EOEnterpriseObjects in another EOEditingContextec
IllegalArgumentException
- if any of the
objects contained in objects
is not
associated with an EOEditingContextlocalInstanceOfObject(com.webobjects.eocontrol.EOEditingContext, com.webobjects.eocontrol.EOEnterpriseObject)
public static EOModelGroup modelGroup(EOEditingContext ec)
ec
- the EOEditingContextIllegalArgumentException
- if the
root object store of ec
as returned by
EOEditingContext.rootObjectStore
is not an
instance of type EOObjectStoreCoordinator
EOEditingContext.rootObjectStore()
,
EOObjectStoreCoordinator
public static EOEnterpriseObject objectFromRawRow(EOEditingContext ec, String name, NSDictionary row)
faultForRawRow
). This method can only be used on raw rows
that include the row's primary key.ec
- an EOEditingContextname
- name of the entityrow
- an NSDictionary of the raw row (or "snapshot")EOEditingContext.faultForRawRow(com.webobjects.foundation.NSDictionary, java.lang.String, com.webobjects.eocontrol.EOEditingContext)
public static EOEnterpriseObject objectMatchingKeyAndValue(EOEditingContext ec, String name, String key, Object value)
ec
- an EOEditingContextname
- the name of the EOEntitykey
- the key for the queryvalue
- the value to matchEOObjectNotAvailableException
- if there is
no matching objectEOUtilities.MoreThanOneException
- if there are
more than one matching objectsobjectMatchingValues(com.webobjects.eocontrol.EOEditingContext, java.lang.String, com.webobjects.foundation.NSDictionary)
,
objectsMatchingKeyAndValue(com.webobjects.eocontrol.EOEditingContext, java.lang.String, java.lang.String, java.lang.Object)
public static EOEnterpriseObject objectMatchingValues(EOEditingContext ec, String name, NSDictionary values)
ec
- an EOEditingContextname
- the name of the EOEntityvalues
- specifies value of Enterprise ObjectEOObjectNotAvailableException
- if there is
no matching objectEOUtilities.MoreThanOneException
- if there are
more than one matching objectsobjectMatchingKeyAndValue(com.webobjects.eocontrol.EOEditingContext, java.lang.String, java.lang.String, java.lang.Object)
,
objectsMatchingValues(com.webobjects.eocontrol.EOEditingContext, java.lang.String, com.webobjects.foundation.NSDictionary)
public static EOEnterpriseObject objectWithFetchSpecificationAndBindings(EOEditingContext ec, String entityName, String fetchSpecName, NSDictionary bindings)
ec
- an EOEditingContextentityName
- the name of the EOEntityfetchSpecName
- the name of the EOFetchSpecificationbindings
- an NSDictionary of bindings for the EOFetchSpecificationEOObjectNotAvailableException
- if there is
no matching objectEOUtilities.MoreThanOneException
- if there are
more than one matching objectsobjectsWithFetchSpecificationAndBindings(com.webobjects.eocontrol.EOEditingContext, java.lang.String, java.lang.String, com.webobjects.foundation.NSDictionary)
public static EOEnterpriseObject objectWithPrimaryKey(EOEditingContext ec, String entityName, NSDictionary pkDict)
ec
- an EOEditingContextentityName
- the name of the EOEntitypkDict
- an NSDictionary containing the primary keyexception
- unless exactly one object is retrievedobjectMatchingKeyAndValue(com.webobjects.eocontrol.EOEditingContext, java.lang.String, java.lang.String, java.lang.Object)
,
objectWithPrimaryKeyValue(com.webobjects.eocontrol.EOEditingContext, java.lang.String, java.lang.Object)
,
primaryKeyForObject(com.webobjects.eocontrol.EOEditingContext, com.webobjects.eocontrol.EOEnterpriseObject)
public static EOEnterpriseObject objectWithPrimaryKeyValue(EOEditingContext ec, String entityName, Object value)
ec
- an EOEditingContextentityName
- the name of the EOEntityvalue
- primary key valuejava.lang.IllegalArgumentException
- if the primary key
is not formed by exactly one attributeEOObjectNotAvailableException
- if there is
no matching objectEOUtilities.MoreThanOneException
- if there are
more than one matching objectsobjectsMatchingValues(com.webobjects.eocontrol.EOEditingContext, java.lang.String, com.webobjects.foundation.NSDictionary)
,
objectWithPrimaryKey(com.webobjects.eocontrol.EOEditingContext, java.lang.String, com.webobjects.foundation.NSDictionary)
public static EOEnterpriseObject objectWithQualifierFormat(EOEditingContext ec, String name, String format, NSArray args)
ec
- an EOEditingContextname
- the name of the EOEntityformat
- format String for the qualifierargs
- arguments for the format StringEOObjectNotAvailableException
- if there is
no matching objectEOUtilities.MoreThanOneException
- if there are
more than one matching objectsobjectsWithQualifierFormat(com.webobjects.eocontrol.EOEditingContext, java.lang.String, java.lang.String, com.webobjects.foundation.NSArray)
,
rawRowsWithQualifierFormat(com.webobjects.eocontrol.EOEditingContext, java.lang.String, java.lang.String, com.webobjects.foundation.NSArray)
public static NSArray objectsForEntityNamed(EOEditingContext ec, String name)
ec
- an EOEditingContextname
- the name of the entityobjectsWithQualifierFormat(com.webobjects.eocontrol.EOEditingContext, java.lang.String, java.lang.String, com.webobjects.foundation.NSArray)
,
objectsMatchingKeyAndValue(com.webobjects.eocontrol.EOEditingContext, java.lang.String, java.lang.String, java.lang.Object)
,
objectsMatchingValues(com.webobjects.eocontrol.EOEditingContext, java.lang.String, com.webobjects.foundation.NSDictionary)
public static NSArray objectsMatchingKeyAndValue(EOEditingContext ec, String name, String key, Object value)
ec
- an EOEditingContextentityName
- the name of the EOEntitykey
- key for queryvalue
- value for propertyobjectMatchingKeyAndValue(com.webobjects.eocontrol.EOEditingContext, java.lang.String, java.lang.String, java.lang.Object)
,
objectsForEntityNamed(com.webobjects.eocontrol.EOEditingContext, java.lang.String)
,
objectsMatchingValues(com.webobjects.eocontrol.EOEditingContext, java.lang.String, com.webobjects.foundation.NSDictionary)
public static NSArray objectsMatchingValues(EOEditingContext ec, String name, NSDictionary values)
ec
- an EOEditingContextname
- the name of the EOEntityvalues
- an NSDictionary of key-value pairsobjectMatchingValues(com.webobjects.eocontrol.EOEditingContext, java.lang.String, com.webobjects.foundation.NSDictionary)
,
objectsForEntityNamed(com.webobjects.eocontrol.EOEditingContext, java.lang.String)
,
objectsMatchingKeyAndValue(com.webobjects.eocontrol.EOEditingContext, java.lang.String, java.lang.String, java.lang.Object)
public static NSArray objectsOfClass(EOEditingContext ec, Class aClass)
ec
- an EOEditingContextaClass
- an EO ClassEOObjectNotAvailableException
- if there no
entity for that classEOUtilities.MoreThanOneException
- if there is more than
one entity for that classentityForClass(com.webobjects.eocontrol.EOEditingContext, java.lang.Class)
public static NSArray objectsWithFetchSpecificationAndBindings(EOEditingContext ec, String entityName, String fetchSpecName, NSDictionary bindings)
ec
- an EOEditingContextentityName
- the name of the EOEntityfetchSpecName
- the name of the EOFetchSpecification for the entitybindings
- an NSDictionary of bindings for EOQualifierVariables in the EOFetchSpecificationEOObjectNotAvailableException
- if the fetch
specification fetchSpecName
couldn't be foundobjectWithFetchSpecificationAndBindings(com.webobjects.eocontrol.EOEditingContext, java.lang.String, java.lang.String, com.webobjects.foundation.NSDictionary)
public static NSArray objectsWithQualifierFormat(EOEditingContext ec, String name, String format, NSArray args)
ec
- an EOEditingContextentityName
- the name of the EOEntityformat
- format string for the qualifierargs
- an NSArray of arguments for the format stringobjectWithQualifierFormat(com.webobjects.eocontrol.EOEditingContext, java.lang.String, java.lang.String, com.webobjects.foundation.NSArray)
,
objectsForEntityNamed(com.webobjects.eocontrol.EOEditingContext, java.lang.String)
public static NSDictionary primaryKeyForObject(EOEditingContext ec, EOEnterpriseObject object)
ec
- an EOEditingContext containing object
object
- the Enterprise Objectobject
objectWithPrimaryKey(com.webobjects.eocontrol.EOEditingContext, java.lang.String, com.webobjects.foundation.NSDictionary)
,
objectWithPrimaryKeyValue(com.webobjects.eocontrol.EOEditingContext, java.lang.String, java.lang.Object)
public static EOQualifier qualifierForEnterpriseObject(EOEditingContext ec, EOEnterpriseObject object)
ec
- an EOEditingContext containing object
object
- the Enterprise Objectobject
an
- IllegalArgumentException if it cannot determine the globalID or entity of object
primaryKeyForObject(com.webobjects.eocontrol.EOEditingContext, com.webobjects.eocontrol.EOEnterpriseObject)
public static NSArray rawRowsForSQL(EOEditingContext ec, String name, String sqlString)
ec
- an EOEditingContextname
- name of the EOModel to usesqlString
- the query string in SQL syntaxrawRowsWithQualifierFormat(com.webobjects.eocontrol.EOEditingContext, java.lang.String, java.lang.String, com.webobjects.foundation.NSArray)
,
rawRowsForStoredProcedureNamed(com.webobjects.eocontrol.EOEditingContext, java.lang.String, com.webobjects.foundation.NSDictionary)
public static NSArray rawRowsForStoredProcedureNamed(EOEditingContext ec, String name, NSDictionary args)
ec
- an EOEditingContextname
- the name of the stored procedure to callargs
- input arguments for the procedurerawRowsForSQL(com.webobjects.eocontrol.EOEditingContext, java.lang.String, java.lang.String)
public static NSArray rawRowsMatchingKeyAndValue(EOEditingContext ec, String name, String key, Object value)
ec
- an EOEditingContextname
- the name of the EOEntitykey
- property keyvalue
- property valueobjectMatchingKeyAndValue(com.webobjects.eocontrol.EOEditingContext, java.lang.String, java.lang.String, java.lang.Object)
,
objectsMatchingKeyAndValue(com.webobjects.eocontrol.EOEditingContext, java.lang.String, java.lang.String, java.lang.Object)
,
rawRowsMatchingValues(com.webobjects.eocontrol.EOEditingContext, java.lang.String, com.webobjects.foundation.NSDictionary)
public static NSArray rawRowsMatchingValues(EOEditingContext ec, String name, NSDictionary values)
ec
- an EOEditingContextname
- the name of the EOEntityvalues
- an NSDictionary of key-value pairsobjectMatchingValues(com.webobjects.eocontrol.EOEditingContext, java.lang.String, com.webobjects.foundation.NSDictionary)
,
objectsMatchingValues(com.webobjects.eocontrol.EOEditingContext, java.lang.String, com.webobjects.foundation.NSDictionary)
,
rawRowsMatchingKeyAndValue(com.webobjects.eocontrol.EOEditingContext, java.lang.String, java.lang.String, java.lang.Object)
public static NSArray rawRowsWithQualifierFormat(EOEditingContext ec, String name, String format, NSArray args)
ec
- an EOEditingContextname
- the name of the EOEntityformat
- format Stringargs
- an NSArray of arguments for the format
StringobjectsWithQualifierFormat(com.webobjects.eocontrol.EOEditingContext, java.lang.String, java.lang.String, com.webobjects.foundation.NSArray)
,
rawRowsForSQL(com.webobjects.eocontrol.EOEditingContext, java.lang.String, java.lang.String)
|
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 |