|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.datanucleus.store.types.sco.SCOUtils
public class SCOUtils
Collection of utilities for second class wrappers and objects.
| Constructor Summary | |
|---|---|
SCOUtils()
|
|
| Method Summary | |
|---|---|
static boolean |
allowNullsInContainer(boolean defaultValue,
AbstractMemberMetaData mmd)
Utility to return whether or not to allow nulls in the container for the specified field. |
static boolean |
arrayIsStoredInSingleColumn(AbstractMemberMetaData fmd,
MetaDataManager mmgr)
Convenience method to return if an array field has the elements stored into the table of the field as a single (BLOB) column. |
static boolean |
attachAddNewElements(ApiAdapter api,
java.util.Collection coll,
java.util.Collection elements,
boolean elementsWithoutId)
Convenience method for use by Collection/Set/HashSet attachCopy methods to add any new elements (added whilst detached) to the collection. |
static void |
attachCopyForCollection(ObjectProvider ownerSM,
java.lang.Object[] detachedElements,
java.util.Collection attached,
boolean elementsWithoutIdentity)
Method to return an attached copy of the passed (detached) value. |
static void |
attachCopyForMap(ObjectProvider ownerSM,
java.util.Set detachedEntries,
java.util.Map attached,
boolean keysWithoutIdentity,
boolean valuesWithoutIdentity)
Method to return an attached copy of the passed (detached) value. |
static void |
attachForCollection(ObjectProvider ownerSM,
java.lang.Object[] elements,
boolean elementsWithoutIdentity)
Convenience method to attach (recursively) all elements for a collection field. |
static void |
attachForMap(ObjectProvider ownerSM,
java.util.Set entries,
boolean keysWithoutIdentity,
boolean valuesWithoutIdentity)
Convenience method to attach (recursively) all keys/values for a map field. |
static boolean |
attachRemoveDeletedElements(ApiAdapter api,
java.util.Collection coll,
java.util.Collection elements,
boolean elementsWithoutId)
Convenience method for use by Collection/Set/HashSet attachCopy methods to remove any no-longer-needed elements from the collection (for when elements are removed when detached). |
static boolean |
collectionHasElementsWithoutIdentity(AbstractMemberMetaData mmd)
Convenience method to return if a collection field has elements without their own identity. |
static boolean |
collectionHasSerialisedElements(AbstractMemberMetaData fmd)
Convenience method to return if a collection field has the elements serialised into the table of the field as a single BLOB. |
static boolean |
detachAsWrapped(ObjectProvider ownerSM)
Convenience accessor for whether to detach SCO objects as wrapped. |
static void |
detachCopyForCollection(ObjectProvider ownerSM,
java.lang.Object[] elements,
FetchPlanState state,
java.util.Collection detached)
Convenience method to detach copies (recursively) of all elements for a collection field. |
static void |
detachCopyForMap(ObjectProvider ownerSM,
java.util.Set entries,
FetchPlanState state,
java.util.Map detached)
Convenience method to detach copies (recursively) of all elements for a map field. |
static void |
detachForCollection(ObjectProvider ownerSM,
java.lang.Object[] elements,
FetchPlanState state)
Convenience method to detach (recursively) all elements for a collection field. |
static void |
detachForMap(ObjectProvider ownerSM,
java.util.Set entries,
FetchPlanState state)
Convenience method to detach (recursively) all elements for a map field. |
static java.util.Comparator |
getComparator(AbstractMemberMetaData fmd,
ClassLoaderResolver clr)
Convenience method for creating a Comparator using extension metadata tags for the specified field. |
static java.lang.String |
getContainerInfoMessage(ObjectProvider ownerSM,
java.lang.String fieldName,
SCOContainer cont,
boolean useCache,
boolean queued,
boolean allowNulls,
boolean lazyLoading)
Utility to generate a message representing the SCO container wrapper and its capabilities. |
static java.lang.Class |
getContainerInstanceType(java.lang.Class declaredType,
java.lang.Boolean ordered)
Method to return the type to instantiate a container as. |
static java.lang.String |
getSCOWrapperOptionsMessage(boolean useCache,
boolean queued,
boolean allowNulls,
boolean lazyLoading)
Convenience method to generate a message containing the options of this SCO wrapper. |
static boolean |
hasDependentElement(AbstractMemberMetaData mmd)
Method to return if the member is a collection/array with dependent element. |
static boolean |
hasDependentKey(AbstractMemberMetaData mmd)
Method to return if the member is a map with dependent key. |
static boolean |
hasDependentValue(AbstractMemberMetaData mmd)
Method to return if the member is a map with dependent value. |
static boolean |
isListBased(java.lang.Class type)
Return whether the supplied type (collection) is list based. |
static boolean |
mapHasKeysWithoutIdentity(AbstractMemberMetaData fmd)
Convenience method to return if a map field has keys without their own identity. |
static boolean |
mapHasSerialisedKeysAndValues(AbstractMemberMetaData fmd)
Convenience method to return if a map field has the keys/values serialised. |
static boolean |
mapHasValuesWithoutIdentity(AbstractMemberMetaData fmd)
Convenience method to return if a map field has values without their own identity. |
static SCO |
newSCOInstance(ObjectProvider ownerSM,
AbstractMemberMetaData fmd,
java.lang.Class declaredType,
java.lang.Class instantiatedType,
java.lang.Object value,
boolean forInsert,
boolean forUpdate,
boolean replaceField)
Method to create a new SCO wrapper for a SCO type. |
static void |
populateMapDelegateWithStoreData(java.util.Map delegate,
MapStore store,
ObjectProvider ownerSM)
Convenience method to populate the passed delegate Map with the keys/values from the associated Store. |
static void |
refreshFetchPlanFieldsForCollection(ObjectProvider ownerSM,
java.lang.Object[] elements)
Convenience method to refresh fetch plan fields for all elements for a collection field. |
static void |
refreshFetchPlanFieldsForMap(ObjectProvider ownerSM,
java.util.Set entries)
Convenience method to refresh fetch plan fields for all elements for a map field. |
static java.lang.Object[] |
toArray(CollectionStore backingStore,
ObjectProvider sm)
Returns true if this collection contains the specified element. |
static java.lang.Object[] |
toArray(CollectionStore backingStore,
ObjectProvider sm,
java.lang.Object[] a)
Returns an array containing all of the elements in this collection; |
static void |
updateCollectionWithCollection(ApiAdapter api,
java.util.Collection coll,
java.util.Collection newColl)
Convenience method to update a collection to contain the elements in another collection. |
static boolean |
updateCollectionWithCollectionElements(java.util.Collection coll,
java.util.Collection elements)
Convenience method for use by Collection/Set/HashSet attachCopy methods to update the passed (attached) collection using the (attached) elements passed. |
static boolean |
updateListWithListElements(java.util.List list,
java.util.List elements)
Convenience method for use by List attachCopy methods to update the passed (attached) list using the (attached) list elements passed. |
static boolean |
updateMapWithMapKeysValues(ApiAdapter api,
java.util.Map map,
java.util.Map keysValues)
Convenience method for use by Map attachCopy methods to update the passed (attached) map using the (attached) map keys/values passed. |
static boolean |
useCachedLazyLoading(ObjectProvider ownerSM,
java.lang.String fieldName)
Accessor for whether the use lazy loading when caching the collection. |
static boolean |
useContainerCache(ObjectProvider ownerSM,
java.lang.String fieldName)
Utility to return whether or not to use the container cache for the collection/map for the passed StateManager SCO. |
static boolean |
useQueuedUpdate(boolean queued,
ObjectProvider sm)
Convenience method to return if we should use a queued update for the current operation. |
static boolean |
validateObjectForWriting(ExecutionContext ec,
java.lang.Object object,
FieldValues2 fieldValues)
Method to check if an object to be stored in a SCO container is already persistent, or is managed by a different ObjectManager. |
static void |
validateObjectsForWriting(ExecutionContext ec,
java.lang.Object objects)
Method to check if objects to be stored in a SCO container are already persistent, or are managed by a different ObjectManager. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public SCOUtils()
| Method Detail |
|---|
public static SCO newSCOInstance(ObjectProvider ownerSM,
AbstractMemberMetaData fmd,
java.lang.Class declaredType,
java.lang.Class instantiatedType,
java.lang.Object value,
boolean forInsert,
boolean forUpdate,
boolean replaceField)
ownerSM - State Manager for the owning objectfmd - The Field MetaData for the related field.declaredType - The class of the objectinstantiatedType - Instantiated type for the field if knownvalue - The value we are wrapping if knownforInsert - Whether the SCO needs inserting in the datastore with this valueforUpdate - Whether the SCO needs updating in the datastore with this valuereplaceField - Whether to replace the field with this value
NucleusUserException - if an error occurred when creating the SCO instance
public static java.lang.String getContainerInfoMessage(ObjectProvider ownerSM,
java.lang.String fieldName,
SCOContainer cont,
boolean useCache,
boolean queued,
boolean allowNulls,
boolean lazyLoading)
ownerSM - StateManager for the ownerfieldName - Field with the containercont - The SCOContaineruseCache - Whether to use caching of values in the containerqueued - Whether operations are queued in the wrapperallowNulls - Whether to allow nullslazyLoading - Whether to use lazy loading in the wrapper
public static java.lang.String getSCOWrapperOptionsMessage(boolean useCache,
boolean queued,
boolean allowNulls,
boolean lazyLoading)
useCache - Whether to cache the value in the wrapper (and not go to the datastore)queued - Whether it supports queueing of updatesallowNulls - Whether it allows null entrieslazyLoading - Whether it is lazy loaded
public static boolean allowNullsInContainer(boolean defaultValue,
AbstractMemberMetaData mmd)
defaultValue - Default value for the containermmd - MetaData for the field/property
public static boolean useContainerCache(ObjectProvider ownerSM,
java.lang.String fieldName)
ownerSM - The StateManager for the SCO fieldfieldName - Name of the field.
public static boolean useCachedLazyLoading(ObjectProvider ownerSM,
java.lang.String fieldName)
ownerSM - StateManager of the owning objectfieldName - Name of the collection/map field
public static boolean collectionHasElementsWithoutIdentity(AbstractMemberMetaData mmd)
mmd - MetaData for the field
public static boolean mapHasKeysWithoutIdentity(AbstractMemberMetaData fmd)
fmd - MetaData for the field
public static boolean mapHasValuesWithoutIdentity(AbstractMemberMetaData fmd)
fmd - MetaData for the field
public static boolean collectionHasSerialisedElements(AbstractMemberMetaData fmd)
fmd - MetaData for the field
public static boolean arrayIsStoredInSingleColumn(AbstractMemberMetaData fmd,
MetaDataManager mmgr)
fmd - MetaData for the fieldmmgr - MetaData manager
public static boolean mapHasSerialisedKeysAndValues(AbstractMemberMetaData fmd)
fmd - MetaData for the field
public static void updateCollectionWithCollection(ApiAdapter api,
java.util.Collection coll,
java.util.Collection newColl)
api - API Adaptercoll - The collection to updatenewColl - The new collection whose elements we need in "coll"
public static boolean attachRemoveDeletedElements(ApiAdapter api,
java.util.Collection coll,
java.util.Collection elements,
boolean elementsWithoutId)
coll - The current (attached) collectionelements - The collection of (attached) elements needed.elementsWithoutId - Whether the elements have no identity
public static boolean attachAddNewElements(ApiAdapter api,
java.util.Collection coll,
java.util.Collection elements,
boolean elementsWithoutId)
coll - The current (attached) collectionelements - The collection of (attached) elements needed.elementsWithoutId - Whether the elements have no identity
public static boolean updateCollectionWithCollectionElements(java.util.Collection coll,
java.util.Collection elements)
coll - The current (attached) collectionelements - The collection of (attached) elements needed.
public static boolean updateListWithListElements(java.util.List list,
java.util.List elements)
list - The current (attached) listelements - The list of (attached) elements needed.
public static boolean updateMapWithMapKeysValues(ApiAdapter api,
java.util.Map map,
java.util.Map keysValues)
api - Api adaptermap - The current (attached) mapkeysValues - The keys/values required
public static void populateMapDelegateWithStoreData(java.util.Map delegate,
MapStore store,
ObjectProvider ownerSM)
The issue here is that we need to load the keys and values in as few calls as possible. The method employed here reads in the keys (if PersistenceCapable), then the values (if PersistenceCapable), and then the "entries" (ids of keys and values) so we can associate the keys to the values.
delegate - The delegatestore - The StoreownerSM - State Manager of the owner of the map.
public static java.lang.Object[] toArray(CollectionStore backingStore,
ObjectProvider sm)
This implementation iterates over the elements in the collection, checking each element in turn for equality with the specified element.
backingStore - the Storesm - the StateManager
public static java.lang.Object[] toArray(CollectionStore backingStore,
ObjectProvider sm,
java.lang.Object[] a)
backingStore - the Storesm - the StateManagera - the array into which the elements of the collection are to
be stored, if it is big enough; otherwise, a new array of the
same runtime type is allocated for this purpose.
java.lang.NullPointerException - if the specified array is null.
java.lang.ArrayStoreException - if the runtime type of the specified array
is not a supertype of the runtime type of every element in this
collection.
public static java.util.Comparator getComparator(AbstractMemberMetaData fmd,
ClassLoaderResolver clr)
fmd - The field that needs the comparatorclr - ClassLoader resolver
public static void refreshFetchPlanFieldsForCollection(ObjectProvider ownerSM,
java.lang.Object[] elements)
ownerSM - StateManager for the owning object with the collectionelements - The elements in the collection
public static void refreshFetchPlanFieldsForMap(ObjectProvider ownerSM,
java.util.Set entries)
ownerSM - StateManager for the owning object with the mapentries - The entries in the map
public static void detachForCollection(ObjectProvider ownerSM,
java.lang.Object[] elements,
FetchPlanState state)
ownerSM - StateManager for the owning object with the collectionelements - The elements in the collectionstate - FetchPlan state
public static void detachCopyForCollection(ObjectProvider ownerSM,
java.lang.Object[] elements,
FetchPlanState state,
java.util.Collection detached)
ownerSM - StateManager for the owning object with the collectionelements - The elements in the collectionstate - FetchPlan statedetached - Collection to add the detached copies to
public static void attachForCollection(ObjectProvider ownerSM,
java.lang.Object[] elements,
boolean elementsWithoutIdentity)
ownerSM - StateManager for the owning object with the collectionelements - The elements to processelementsWithoutIdentity - Whether the elements have their own identity
public static void attachCopyForCollection(ObjectProvider ownerSM,
java.lang.Object[] detachedElements,
java.util.Collection attached,
boolean elementsWithoutIdentity)
ownerSM - StateManager for the owning object with the collectiondetachedElements - The detached elements in the collectionattached - Collection to add the attached copies toelementsWithoutIdentity - Whether the elements have their own identity
public static void detachForMap(ObjectProvider ownerSM,
java.util.Set entries,
FetchPlanState state)
ownerSM - StateManager for the owning object with the mapentries - The entries in the mapstate - FetchPlan state
public static void detachCopyForMap(ObjectProvider ownerSM,
java.util.Set entries,
FetchPlanState state,
java.util.Map detached)
ownerSM - StateManager for the owning object with the mapentries - The entries in the mapstate - FetchPlan statedetached - Map to add the detached copies to
public static void attachForMap(ObjectProvider ownerSM,
java.util.Set entries,
boolean keysWithoutIdentity,
boolean valuesWithoutIdentity)
ownerSM - StateManager for the owning object with the mapentries - The entries in the map to processkeysWithoutIdentity - Whether the keys have their own identityvaluesWithoutIdentity - Whether the values have their own identity
public static void attachCopyForMap(ObjectProvider ownerSM,
java.util.Set detachedEntries,
java.util.Map attached,
boolean keysWithoutIdentity,
boolean valuesWithoutIdentity)
ownerSM - StateManager for the owning object with the mapdetachedEntries - The detached entries in the mapattached - Map to add the attached copies tokeysWithoutIdentity - Whether the keys have their own identityvaluesWithoutIdentity - Whether the values have their own identity
public static boolean validateObjectForWriting(ExecutionContext ec,
java.lang.Object object,
FieldValues2 fieldValues)
ec - ExecutionContext that we are usingobject - The objectfieldValues - Values for any fields when persisting (if the object needs persisting)
public static void validateObjectsForWriting(ExecutionContext ec,
java.lang.Object objects)
ec - execution contextobjects - The objects (array, or Collection)public static boolean isListBased(java.lang.Class type)
public static java.lang.Class getContainerInstanceType(java.lang.Class declaredType,
java.lang.Boolean ordered)
declaredType - The declared typeordered - Hint whether it needs ordering or not (null implies not)
public static boolean detachAsWrapped(ObjectProvider ownerSM)
ownerSM - StateManager
public static boolean useQueuedUpdate(boolean queued,
ObjectProvider sm)
queued - Whether supporting queued operationssm - StateManager
public static boolean hasDependentElement(AbstractMemberMetaData mmd)
mmd - member metadata
public static boolean hasDependentKey(AbstractMemberMetaData mmd)
mmd - member metadata
public static boolean hasDependentValue(AbstractMemberMetaData mmd)
mmd - member metadata
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||