|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jpox.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 fmd)
Utility to return whether or not to allow nulls in the container for the specified field. |
static boolean |
arrayIsStoredInSingleColumn(AbstractMemberMetaData fmd)
Convenience method to return if an array field has the elements stored into the table of the field as a single (BLOB) column. |
static void |
attachCopyForCollection(StateManager 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(StateManager 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(StateManager ownerSM,
java.lang.Object[] elements,
boolean elementsWithoutIdentity)
Convenience method to attach (recursively) all elements for a collection field. |
static void |
attachForMap(StateManager ownerSM,
java.util.Set entries,
boolean keysWithoutIdentity,
boolean valuesWithoutIdentity)
Convenience method to attach (recursively) all elements for a map field. |
static boolean |
collectionHasElementsWithoutIdentity(AbstractMemberMetaData fmd)
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 void |
detachCopyForCollection(StateManager 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(StateManager 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(StateManager ownerSM,
java.lang.Object[] elements,
FetchPlanState state)
Convenience method to detach (recursively) all elements for a collection field. |
static void |
detachForMap(StateManager 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(StateManager 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.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 |
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 into the table of the field as a single BLOB. |
static boolean |
mapHasValuesWithoutIdentity(AbstractMemberMetaData fmd)
Convenience method to return if a map field has values without their own identity. |
static SCO |
newSCOInstance(StateManager 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,
StateManager ownerSM)
Convenience method to populate the passed delegate Map with the keys/values from the associated Store. |
static void |
refreshFetchPlanFieldsForCollection(StateManager ownerSM,
java.lang.Object[] elements)
Convenience method to refresh fetch plan fields for all elements for a collection field. |
static void |
refreshFetchPlanFieldsForMap(StateManager 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,
StateManager sm)
Returns true if this collection contains the specified element. |
static java.lang.Object[] |
toArray(CollectionStore backingStore,
StateManager 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 void |
updateStoreWithCollection(CollectionStore store,
StateManager ownerSM,
java.util.Collection newColl)
Convenience method to update a Store collection to contain the elements in another collection. |
static boolean |
useCachedLazyLoading(StateManager ownerSM,
java.lang.String fieldName)
Accessor for whether the use lazy loading when caching the collection. |
static boolean |
useContainerCache(StateManager 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 |
useContainerQueueing(StateManager ownerSM)
Utility to return whether to use queueing of operations in the SCO container. |
static boolean |
validateObjectForWriting(ObjectManager om,
java.lang.Object object,
FieldValues 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(ObjectManager om,
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(StateManager 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
JPOXUserException - if an error occurred when creating the SCO instance
public static java.lang.String getContainerInfoMessage(StateManager 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 fmd)
defaultValue - Default value for the containerfmd - MetaData for the field/property
public static boolean useContainerQueueing(StateManager ownerSM)
ownerSM - The StateManager for the SCO field
public static boolean useContainerCache(StateManager ownerSM,
java.lang.String fieldName)
ownerSM - The StateManager for the SCO fieldfieldName - Name of the field.
public static boolean useCachedLazyLoading(StateManager ownerSM,
java.lang.String fieldName)
ownerSM - StateManager of the owning objectfieldName - Name of the collection/map field
public static boolean collectionHasElementsWithoutIdentity(AbstractMemberMetaData fmd)
fmd - 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)
fmd - MetaData for the field
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 void updateStoreWithCollection(CollectionStore store,
StateManager ownerSM,
java.util.Collection newColl)
store - The store to apply changes toownerSM - StateManager of the ownernewColl - The new collection whose elements we need in "coll"
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 - TODOmap - The current (attached) mapkeysValues - The keys/values required
public static void populateMapDelegateWithStoreData(java.util.Map delegate,
MapStore store,
StateManager 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,
StateManager 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,
StateManager 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(StateManager ownerSM,
java.lang.Object[] elements)
ownerSM - StateManager for the owning object with the collectionelements - The elements in the collection
public static void refreshFetchPlanFieldsForMap(StateManager ownerSM,
java.util.Set entries)
ownerSM - StateManager for the owning object with the mapentries - The entries in the map
public static void detachForCollection(StateManager 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(StateManager 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(StateManager ownerSM,
java.lang.Object[] elements,
boolean elementsWithoutIdentity)
ownerSM - StateManager for the owning object with the collectionelements - The elements in the collectionelementsWithoutIdentity - Whether the elements have their own identity
public static void attachCopyForCollection(StateManager 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(StateManager 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(StateManager 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(StateManager ownerSM,
java.util.Set entries,
boolean keysWithoutIdentity,
boolean valuesWithoutIdentity)
ownerSM - StateManager for the owning object with the mapentries - The entries in the mapkeysWithoutIdentity - Whether the keys have their own identityvaluesWithoutIdentity - Whether the values have their own identity
public static void attachCopyForMap(StateManager 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(ObjectManager om,
java.lang.Object object,
FieldValues fieldValues)
om - ObjectManager that we are usingobject - The objectfieldValues - Values for any fields when persisting (if the object needs persisting)
public static void validateObjectsForWriting(ObjectManager om,
java.lang.Object objects)
om - ObjectManager being usedobjects - The objects (array, or Collection)public static boolean isListBased(java.lang.Class type)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||