T
- eo class to representpublic class EOEnterpriseObjectClazz<T extends com.webobjects.eocontrol.EOEnterpriseObject> extends Object
Instead of using a static method, we can use a static inner class (a clazz) instead. This allows for the methods on the clazz to be available statically to the class. The advantage is that static utility methods don't need to be generated for every subclass of an EOEnterpriseObject. It is generally sufficient to simply use the utility methods available on the EOEnterpriseObjectClazz.
Every subclass of this class will get their own "ClazzObject" instance, so it's OK to store things which might be different in superclasses. That is, the "User"'s implementation can override the "Person"'s and because Person.clazz() will get it's own instance, it will do only "Person" things.
Use subclasses of EOEnterpriseObjectClazz as inner classes in your EO subclasses to work around the missing class object inheritance of java. They must be named XX.XXClazz to work.
The methods from EOUtilities are mirrored here so you don't have to import EOAccess in your subclasses, which is not legal for client-side classes. The implementation for a client-side class could then be easily switched to use the server-side EOUtilites implementation.
Modifier and Type | Class and Description |
---|---|
static interface |
EOEnterpriseObjectClazz.ClazzFactory
Provides a hook to control how a clazz object is chosen from a given entity.
|
static class |
EOEnterpriseObjectClazz.DefaultClazzFactory
Default factory implementation.
|
Constructor and Description |
---|
EOEnterpriseObjectClazz()
Default public constructor.
|
EOEnterpriseObjectClazz(String entityName)
Constructor that also supplies an entity name.
|
Modifier and Type | Method and Description |
---|---|
NSArray<T> |
allObjects(com.webobjects.eocontrol.EOEditingContext ec)
Gets all of the objects for the clazz's entity.
|
com.webobjects.eocontrol.EOClassDescription |
classDescription()
Returns the class description for the entity.
|
static EOEnterpriseObjectClazz |
clazzForEntityNamed(String entityName)
Method used to get a clazz object for a given entity name.
|
T |
createAndInsertObject(com.webobjects.eocontrol.EOEditingContext ec)
Creates and inserts an object of the type of
the clazz into the given editing context.
|
ERXFetchSpecification<T> |
createFetchSpecification(com.webobjects.eocontrol.EOQualifier qualifier,
NSArray<com.webobjects.eocontrol.EOSortOrdering> sortings)
Creates a fetch spec for the entity.
|
protected void |
discoverEntityName() |
com.webobjects.eoaccess.EOEntity |
entity()
Gets the entity corresponding to the entity
name of the clazz.
|
com.webobjects.eoaccess.EOEntity |
entity(com.webobjects.eocontrol.EOEditingContext ec)
Gets the entity corresponding to the entity
name of the clazz.
|
String |
entityName()
Gets the entity name of the clazz.
|
protected String |
entityNameFromRawRow(com.webobjects.eocontrol.EOEditingContext ec,
NSDictionary dict)
Utility method to get the entity name from a raw row dictionary, taking subclasses and restricting qualifiers into account.
|
static EOEnterpriseObjectClazz.ClazzFactory |
factory() |
NSArray<T> |
faultsFromRawRows(com.webobjects.eocontrol.EOEditingContext ec,
NSArray nsarray)
Constructs an array of faults for a given array
of primary keys in a given editing context for
the clazz's entity.
|
NSArray<T> |
faultsMatchingQualifier(com.webobjects.eocontrol.EOEditingContext ec,
com.webobjects.eocontrol.EOQualifier eoqualifier)
Fetches an array of faults matching a given qualifier.
|
NSArray<T> |
faultsMatchingQualifier(com.webobjects.eocontrol.EOEditingContext ec,
com.webobjects.eocontrol.EOQualifier eoqualifier,
NSArray<com.webobjects.eocontrol.EOSortOrdering> sortOrderings)
Fetches an array of faults matching a given qualifier
and sorted by an array of sort orderings.
|
NSArray<T> |
faultsMatchingValues(com.webobjects.eocontrol.EOEditingContext ec,
NSDictionary nsdictionary,
NSArray<com.webobjects.eocontrol.EOSortOrdering> sortOrderings)
Fetches an array of faults for a given set of criteria.
|
com.webobjects.eocontrol.EOFetchSpecification |
fetchSpecificationNamed(com.webobjects.eocontrol.EOEditingContext ec,
String name)
Gets a fetch specification for a given name.
|
com.webobjects.eocontrol.EOFetchSpecification |
fetchSpecificationNamed(String name)
Gets a fetch specification for a given name.
|
NSArray<T> |
filteredArray(NSArray<T> array,
com.webobjects.eocontrol.EOFetchSpecification spec,
NSDictionary bindings)
Filters an array with a given fetch spec.
|
EOEnterpriseObjectClazz |
init(String entityName)
Convenience init so you can chain constructor calls:
|
protected void |
initialize()
Called by the constructor.
|
com.webobjects.eocontrol.EOArrayDataSource |
newArrayDataSource(com.webobjects.eocontrol.EOEditingContext ec)
Utility to return a new array datasource
|
com.webobjects.eoaccess.EODatabaseDataSource |
newDatabaseDataSource(com.webobjects.eocontrol.EOEditingContext ec)
Utility to return a new database datasource
|
NSArray |
newPrimaryKeys(com.webobjects.eocontrol.EOEditingContext ec,
int i)
Generates an array of primary key values for
the clazz's entity.
|
protected static EOAttribute |
objectCountAttribute()
Creates and caches an eo attribute that can be
used to return the number of objects that a given
fetch specification will return.
|
protected static EOAttribute |
objectCountUniqueAttribute(EOAttribute foo) |
Number |
objectCountWithFetchSpecificationAndBindings(com.webobjects.eocontrol.EOEditingContext ec,
String fetchSpecName,
NSDictionary bindings)
Find the number of objects matching the given fetch
specification and bindings for the clazz's entity
name.
|
Number |
objectCountWithQualifier(com.webobjects.eocontrol.EOEditingContext ec,
com.webobjects.eocontrol.EOQualifier qualifier)
Returns the number of objects matching the given
qualifier for the clazz's entity name.
|
T |
objectFromRawRow(com.webobjects.eocontrol.EOEditingContext ec,
NSDictionary dict)
Creates an enterprise object from a raw row
for the clazz's entity in the given editing context.
|
T |
objectMatchingKeyAndValue(com.webobjects.eocontrol.EOEditingContext ec,
String key,
Object value)
Fetches the object matching the given key and value
corresponding to the clazz's entity using the
given editing context.
|
NSArray<T> |
objectsMatchingKeyAndValue(com.webobjects.eocontrol.EOEditingContext ec,
String key,
Object value)
Fetches all of the objects matching the given key and value
corresponding to the clazz's entity using the
given editing context.
|
NSArray<T> |
objectsMatchingQualifier(com.webobjects.eocontrol.EOEditingContext ec,
com.webobjects.eocontrol.EOQualifier qualifier) |
NSArray<T> |
objectsMatchingQualifier(com.webobjects.eocontrol.EOEditingContext ec,
com.webobjects.eocontrol.EOQualifier qualifier,
NSArray<com.webobjects.eocontrol.EOSortOrdering> sortOrdering) |
NSArray<T> |
objectsWithFetchSpecificationAndBindings(com.webobjects.eocontrol.EOEditingContext ec,
String name,
NSDictionary bindings)
Fetches an array of objects for a given fetch specification
and an array of bindings.
|
NSArray<T> |
objectsWithQualifierFormat(com.webobjects.eocontrol.EOEditingContext ec,
String qualifier,
NSArray args)
Fetches all of the objects matching the given qualifier
format corresponding to the clazz's entity using the
given editing context.
|
T |
objectWithPrimaryKeyValue(com.webobjects.eocontrol.EOEditingContext ec,
Object pk)
Fetches the enterprise object for the specified
primary key value and corresponding to the clazz's
entity name.
|
com.webobjects.eocontrol.EOFetchSpecification |
primaryKeyFetchSpecificationForEntity(com.webobjects.eocontrol.EOQualifier qualifier,
NSArray<com.webobjects.eocontrol.EOSortOrdering> sortOrderings,
NSArray<String> additionalKeys)
Constructs a fetch specification that will only fetch the primary
keys for a given qualifier.
|
NSArray |
primaryKeysMatchingQualifier(com.webobjects.eocontrol.EOEditingContext ec,
com.webobjects.eocontrol.EOQualifier eoqualifier,
NSArray sortOrderings)
Fetches an array of primary keys matching a given qualifier
and sorted with a given array of sort orderings.
|
NSArray |
primaryKeysMatchingValues(com.webobjects.eocontrol.EOEditingContext ec,
NSDictionary nsdictionary,
NSArray sortOrderings)
Fetches an array of primary keys matching the values
in a given dictionary.
|
static void |
resetClazzCache()
Resets the clazz cache.
|
protected void |
setEntityName(String name)
Sets the entity name of the clazz.
|
static void |
setFactory(EOEnterpriseObjectClazz.ClazzFactory value) |
public EOEnterpriseObjectClazz()
public static FooClazz clazz = new FooClazz();
and the constructor will auto-discover your entity name. This only
works when you have a concrete subclass for the entity in question, though.public EOEnterpriseObjectClazz(String entityName)
entityName
- entity nameprotected static EOAttribute objectCountAttribute()
protected static EOAttribute objectCountUniqueAttribute(EOAttribute foo)
foo
- protected void initialize()
protected void discoverEntityName()
public EOEnterpriseObjectClazz init(String entityName)
public static FooClazz clazz = (FooClazz)new FooClazz().init("Foo");
without having to override the default constructor or the one
that takes an entity name. Also useful when you don't have a special
clazz defined for your entity, but would rather take one from a superclass.entityName
- entity namepublic com.webobjects.eocontrol.EOClassDescription classDescription()
public com.webobjects.eocontrol.EOArrayDataSource newArrayDataSource(com.webobjects.eocontrol.EOEditingContext ec)
ec
- an editing contextpublic com.webobjects.eoaccess.EODatabaseDataSource newDatabaseDataSource(com.webobjects.eocontrol.EOEditingContext ec)
ec
- an editing contextpublic static void resetClazzCache()
public static EOEnterpriseObjectClazz clazzForEntityNamed(String entityName)
entityName
- name of the entity to get the Clazz object forpublic T createAndInsertObject(com.webobjects.eocontrol.EOEditingContext ec)
ec
- an editing contextpublic NSArray newPrimaryKeys(com.webobjects.eocontrol.EOEditingContext ec, int i)
ec
- an editing contexti
- number of primary keys to generatepublic NSArray<T> allObjects(com.webobjects.eocontrol.EOEditingContext ec)
EOUtilities
method objectsForEntityNamed
.ec
- editing context to fetch the objects intopublic T objectFromRawRow(com.webobjects.eocontrol.EOEditingContext ec, NSDictionary dict)
ec
- editing context to create the eo indict
- raw row dictionaryprotected String entityNameFromRawRow(com.webobjects.eocontrol.EOEditingContext ec, NSDictionary dict)
ec
- an editing contextdict
- raw row dictionarypublic T objectWithPrimaryKeyValue(com.webobjects.eocontrol.EOEditingContext ec, Object pk)
ec
- editing context to fetch intopk
- primary key value. Compound primary keys are given as NSDictionaries.public NSArray<T> objectsWithQualifierFormat(com.webobjects.eocontrol.EOEditingContext ec, String qualifier, NSArray args)
ec
- editing contextqualifier
- qualifier stringargs
- qualifier format argumentspublic NSArray<T> objectsMatchingKeyAndValue(com.webobjects.eocontrol.EOEditingContext ec, String key, Object value)
ec
- editing contextkey
- key stringvalue
- valuepublic NSArray<T> objectsMatchingQualifier(com.webobjects.eocontrol.EOEditingContext ec, com.webobjects.eocontrol.EOQualifier qualifier)
public NSArray<T> objectsMatchingQualifier(com.webobjects.eocontrol.EOEditingContext ec, com.webobjects.eocontrol.EOQualifier qualifier, NSArray<com.webobjects.eocontrol.EOSortOrdering> sortOrdering)
public T objectMatchingKeyAndValue(com.webobjects.eocontrol.EOEditingContext ec, String key, Object value)
ec
- editing contextkey
- key stringvalue
- valuepublic NSArray<T> objectsWithFetchSpecificationAndBindings(com.webobjects.eocontrol.EOEditingContext ec, String name, NSDictionary bindings)
ec
- editing content to fetch intoname
- fetch specification namebindings
- used to resolve binding keys within the fetch
specificationprotected void setEntityName(String name)
name
- of the entitypublic String entityName()
public com.webobjects.eoaccess.EOEntity entity()
public com.webobjects.eoaccess.EOEntity entity(com.webobjects.eocontrol.EOEditingContext ec)
ec
- an editing contextpublic com.webobjects.eocontrol.EOFetchSpecification fetchSpecificationNamed(String name)
name
- of the fetch specificationpublic com.webobjects.eocontrol.EOFetchSpecification fetchSpecificationNamed(com.webobjects.eocontrol.EOEditingContext ec, String name)
ec
- editing context to use for finding the model groupname
- of the fetch specificationpublic ERXFetchSpecification<T> createFetchSpecification(com.webobjects.eocontrol.EOQualifier qualifier, NSArray<com.webobjects.eocontrol.EOSortOrdering> sortings)
public NSArray<T> filteredArray(NSArray<T> array, com.webobjects.eocontrol.EOFetchSpecification spec, NSDictionary bindings)
array
- spec
- bindings
- public Number objectCountWithQualifier(com.webobjects.eocontrol.EOEditingContext ec, com.webobjects.eocontrol.EOQualifier qualifier)
ec
- editing context to use for the count qualificationqualifier
- to find the matching objectspublic Number objectCountWithFetchSpecificationAndBindings(com.webobjects.eocontrol.EOEditingContext ec, String fetchSpecName, NSDictionary bindings)
ec
- ec used to perform the count infetchSpecName
- name of the fetch specificationbindings
- dictionary of bindings for the fetch
specificationpublic com.webobjects.eocontrol.EOFetchSpecification primaryKeyFetchSpecificationForEntity(com.webobjects.eocontrol.EOQualifier qualifier, NSArray<com.webobjects.eocontrol.EOSortOrdering> sortOrderings, NSArray<String> additionalKeys)
qualifier
- to construct the fetch spec withsortOrderings
- array of sort orderings to sort the result
set with.additionalKeys
- array of additional key paths to construct
the raw rows key paths to fetch.public NSArray primaryKeysMatchingQualifier(com.webobjects.eocontrol.EOEditingContext ec, com.webobjects.eocontrol.EOQualifier eoqualifier, NSArray sortOrderings)
ec
- editing context to fetch intoeoqualifier
- to restrict matching primary keyssortOrderings
- array of sort orders to sort result setpublic NSArray primaryKeysMatchingValues(com.webobjects.eocontrol.EOEditingContext ec, NSDictionary nsdictionary, NSArray sortOrderings)
ec
- editing context to fetch intonsdictionary
- dictionary of key value pairs to match
against.sortOrderings
- array of sort orders to sort the result set
by.public NSArray<T> faultsFromRawRows(com.webobjects.eocontrol.EOEditingContext ec, NSArray nsarray)
ec
- editing context to construct the faults innsarray
- array of primary key dictionariespublic NSArray<T> faultsMatchingQualifier(com.webobjects.eocontrol.EOEditingContext ec, com.webobjects.eocontrol.EOQualifier eoqualifier)
ec
- editing context to use to fetch intoeoqualifier
- qualifier to match againstpublic NSArray<T> faultsMatchingQualifier(com.webobjects.eocontrol.EOEditingContext ec, com.webobjects.eocontrol.EOQualifier eoqualifier, NSArray<com.webobjects.eocontrol.EOSortOrdering> sortOrderings)
ec
- editing context to use to fetch intoeoqualifier
- qualifier to match againstsortOrderings
- array of sort orderings to order the faultspublic NSArray<T> faultsMatchingValues(com.webobjects.eocontrol.EOEditingContext ec, NSDictionary nsdictionary, NSArray<com.webobjects.eocontrol.EOSortOrdering> sortOrderings)
ec
- editing context to use to fetch intonsdictionary
- key value criteria to match againstsortOrderings
- array of sort orderings to order the faultspublic static EOEnterpriseObjectClazz.ClazzFactory factory()
public static void setFactory(EOEnterpriseObjectClazz.ClazzFactory value)
Copyright © 2002 – 2020 Project Wonder.