org.datanucleus.api
Interface ApiAdapter

All Superinterfaces:
java.io.Serializable
All Known Implementing Classes:
JDOAdapter

public interface ApiAdapter
extends java.io.Serializable

Adapter to allow the core runtime to expose multiple APIs to clients.


Method Summary
 boolean allowDeleteOfNonPersistentObject()
          Whether the API allows deletion of a non-persistent object.
 boolean allowPersistOfDeletedObject()
          Whether the API allows (re-)persistence of a deleted object.
 boolean allowReadFieldOfDeletedObject()
          Whether the API allows reading a field of a deleted object.
 boolean clearLoadedFlagsOnDeleteObject()
          Whether the API requires clearing of the fields of an object when it is deleted.
 java.lang.RuntimeException getDataStoreExceptionForException(java.lang.String msg, java.lang.Exception e)
          Convenience method to return a datastore exception appropriate for this API.
 boolean getDefaultCascadeDeleteForField()
          Method to return the default setting for cascading delete of a field
 boolean getDefaultCascadePersistForField()
          Method to return the default setting for cascading persist of a field
 boolean getDefaultCascadeRefreshForField()
          Method to return the default setting for cascading refresh of a field
 boolean getDefaultCascadeUpdateForField()
          Method to return the default setting for cascading update of a field
 java.util.Map getDefaultFactoryProperties()
          Method to return a set of default properties for the factory (PMF, EMF, etc)
 java.lang.Object getIdForObject(java.lang.Object obj)
          Method to return the object identity for the passed persistable object.
 java.lang.Class getKeyTypeForSingleFieldIdentityType(java.lang.Class idType)
          Accessor for the type of the single field application-identity key given the single field identity type.
 LifeCycleState getLifeCycleState(int stateType)
          Returns the LifeCycleState for the state constant.
 java.lang.String getName()
          Accessor for the name of the API.
 java.lang.Object getNewApplicationIdentityObjectId(ClassLoaderResolver clr, AbstractClassMetaData acmd, java.lang.String value)
          Utility to create a new application-identity when you know the metadata for the target class, and the toString() output of the identity.
 java.lang.Object getNewApplicationIdentityObjectId(java.lang.Class cls, java.lang.Object key)
          Method to return a new object identity for the specified class, and key (possibly toString() output).
 java.lang.Object getNewApplicationIdentityObjectId(java.lang.Object pc, AbstractClassMetaData cmd)
          Method to create a new application-identity for the passed object with the supplied MetaData.
 java.lang.Object getNewSingleFieldIdentity(java.lang.Class idType, java.lang.Class pcType, java.lang.Object value)
          Utility to create a new SingleFieldIdentity using reflection when you know the type of the PersistenceCapable, and also which SingleFieldIdentity, and the value of the key.
 java.lang.Object getObjectId(StateManager sm)
          Accessor for the object id from the StateManager for this object.
 ObjectManager getObjectManager(java.lang.Object pc)
          Method to return the ObjectManager (if any) associated with the passed object.
 java.lang.String getObjectState(java.lang.Object obj)
          Accessor for the object state.
 java.lang.Object getPersistenceManager(java.lang.Object obj)
          Accessor for the persistence manager for this object.
 java.lang.String getSingleFieldIdentityClassNameForByte()
          Accessor for the class name to use for identities when there is a single Byte/byte field.
 java.lang.String getSingleFieldIdentityClassNameForChar()
          Accessor for the class name to use for identities when there is a single Character/char field.
 java.lang.String getSingleFieldIdentityClassNameForInt()
          Accessor for the class name to use for identities when there is a single Integer/int field.
 java.lang.String getSingleFieldIdentityClassNameForLong()
          Accessor for the class name to use for identities when there is a single Long/long field.
 java.lang.String getSingleFieldIdentityClassNameForObject()
          Accessor for the class name to use for identities when there is a single Object field.
 java.lang.String getSingleFieldIdentityClassNameForShort()
          Accessor for the class name to use for identities when there is a single Short/short field.
 java.lang.String getSingleFieldIdentityClassNameForString()
          Accessor for the class name to use for identities when there is a single String field.
 java.lang.Class getTargetClassForSingleFieldIdentity(java.lang.Object id)
          Accessor for the target class for the specified single field identity.
 java.lang.String getTargetClassNameForSingleFieldIdentity(java.lang.Object id)
          Accessor for the target class name for the specified single field identity.
 java.lang.Object getTargetKeyForSingleFieldIdentity(java.lang.Object id)
          Accessor for the key object for the specified single field identity.
 java.lang.RuntimeException getUserExceptionForException(java.lang.String msg, java.lang.Exception e)
          Convenience method to return a user exception appropriate for this API when an unexpected exception occurs.
 java.lang.Object getVersion(StateManager sm)
          Accessor for the version from the StateManager for this object.
 java.lang.Object getVersionForObject(java.lang.Object obj)
          Method to return the object version for the passed persistable object.
 boolean isDatastoreIdentity(java.lang.Object id)
          Accessor for whether the passed identity is a valid datastore-identity for this API.
 boolean isDeleted(java.lang.Object obj)
          Accessor for whether the passed object is deleted.
 boolean isDetachable(java.lang.Object obj)
          Method to return if the passed object is detachable using this API.
 boolean isDetached(java.lang.Object obj)
          Accessor for whether the passed object is detached.
 boolean isDirty(java.lang.Object obj)
          Accessor for whether the passed object is dirty.
 boolean isLoaded(StateManager sm, int fieldNumber)
          Accessor for whether a field is loaded for the object managed by the StateManager
 boolean isNew(java.lang.Object obj)
          Accessor for whether the passed object is new.
 boolean isPersistable(java.lang.Class cls)
          Utility method to check if the specified class is of a type that can be persisted for this API.
 boolean isPersistable(java.lang.Object obj)
          Method to return if the passed object is persistable using this API.
 boolean isPersistent(java.lang.Object obj)
          Accessor for whether the passed object is persistent.
 boolean isSingleFieldIdentity(java.lang.Object id)
          Accessor for whether the passed identity is a valid single-field application-identity for this API.
 boolean isSingleFieldIdentityClass(java.lang.String className)
          Accessor for whether the passed class name is a valid single-field application-identity for this API.
 boolean isTransactional(java.lang.Object obj)
          Accessor for whether the passed object is transactional.
 boolean isValidPrimaryKeyClass(java.lang.Class pkClass, AbstractClassMetaData cmd, ClassLoaderResolver clr, int noOfPkFields, MetaDataManager mmgr)
          Utility to check if a primary-key class is valid.
 void makeFieldDirty(java.lang.Object obj, java.lang.String fieldName)
          Method to make the field dirty in the object.
 StateManager newStateManager(ObjectManager om, AbstractClassMetaData acmd)
          Method to create a new StateManager for the ObjectManager and class.
 

Method Detail

getName

java.lang.String getName()
Accessor for the name of the API.

Returns:
Name of the API

getObjectManager

ObjectManager getObjectManager(java.lang.Object pc)
Method to return the ObjectManager (if any) associated with the passed object. Supports persistable objects, and PersistenceManager.

Parameters:
pc - The object
Returns:
The ObjectManager

newStateManager

StateManager newStateManager(ObjectManager om,
                             AbstractClassMetaData acmd)
Method to create a new StateManager for the ObjectManager and class.

Parameters:
om - ObjectManager
acmd - MetaData for the class/interface

getLifeCycleState

LifeCycleState getLifeCycleState(int stateType)
Returns the LifeCycleState for the state constant.

Parameters:
stateType - the type as integer
Returns:
the type as LifeCycleState object

isPersistent

boolean isPersistent(java.lang.Object obj)
Accessor for whether the passed object is persistent.

Parameters:
obj - The object
Returns:
Whether it is persistent

isNew

boolean isNew(java.lang.Object obj)
Accessor for whether the passed object is new.

Parameters:
obj - The object
Returns:
Whether it is new

isDirty

boolean isDirty(java.lang.Object obj)
Accessor for whether the passed object is dirty.

Parameters:
obj - The object
Returns:
Whether it is dirty

isDeleted

boolean isDeleted(java.lang.Object obj)
Accessor for whether the passed object is deleted.

Parameters:
obj - The object
Returns:
Whether it is deleted

isDetached

boolean isDetached(java.lang.Object obj)
Accessor for whether the passed object is detached.

Parameters:
obj - The object
Returns:
Whether it is detached

isTransactional

boolean isTransactional(java.lang.Object obj)
Accessor for whether the passed object is transactional.

Parameters:
obj - The object
Returns:
Whether it is transactional

isPersistable

boolean isPersistable(java.lang.Object obj)
Method to return if the passed object is persistable using this API.

Parameters:
obj - The object
Returns:
Whether it is persistable

isPersistable

boolean isPersistable(java.lang.Class cls)
Utility method to check if the specified class is of a type that can be persisted for this API.

Parameters:
cls - The class to check
Returns:
Whether the class is persistable using this API.

isDetachable

boolean isDetachable(java.lang.Object obj)
Method to return if the passed object is detachable using this API.

Parameters:
obj - The object
Returns:
Whether it is detachable

getObjectState

java.lang.String getObjectState(java.lang.Object obj)
Accessor for the object state.

Parameters:
obj - Object
Returns:
The state ("persistent-clean", "detached-dirty" etc)

getIdForObject

java.lang.Object getIdForObject(java.lang.Object obj)
Method to return the object identity for the passed persistable object. Returns null if it is not persistable, or has no identity.

Parameters:
obj - The object
Returns:
The identity

getVersionForObject

java.lang.Object getVersionForObject(java.lang.Object obj)
Method to return the object version for the passed persistable object. Returns null if it is not persistable, or not versioned.

Parameters:
obj - The object
Returns:
The version

isValidPrimaryKeyClass

boolean isValidPrimaryKeyClass(java.lang.Class pkClass,
                               AbstractClassMetaData cmd,
                               ClassLoaderResolver clr,
                               int noOfPkFields,
                               MetaDataManager mmgr)
Utility to check if a primary-key class is valid. Will throw a InvalidPrimaryKeyException if it is invalid, otherwise returning true.

Parameters:
pkClass - The Primary Key class
cmd - AbstractClassMetaData for the PersistenceCapable class
clr - the ClassLoaderResolver
noOfPkFields - Number of primary key fields
mmgr - MetaData manager
Returns:
Whether it is valid

isSingleFieldIdentity

boolean isSingleFieldIdentity(java.lang.Object id)
Accessor for whether the passed identity is a valid single-field application-identity for this API.

Returns:
Whether it is valid

isDatastoreIdentity

boolean isDatastoreIdentity(java.lang.Object id)
Accessor for whether the passed identity is a valid datastore-identity for this API.

Returns:
Whether it is valid

isSingleFieldIdentityClass

boolean isSingleFieldIdentityClass(java.lang.String className)
Accessor for whether the passed class name is a valid single-field application-identity for this API.

Parameters:
className - Name of the class
Returns:
Whether it is valid

getSingleFieldIdentityClassNameForLong

java.lang.String getSingleFieldIdentityClassNameForLong()
Accessor for the class name to use for identities when there is a single Long/long field.

Returns:
Class name of identity class

getSingleFieldIdentityClassNameForInt

java.lang.String getSingleFieldIdentityClassNameForInt()
Accessor for the class name to use for identities when there is a single Integer/int field.

Returns:
Class name of identity class

getSingleFieldIdentityClassNameForShort

java.lang.String getSingleFieldIdentityClassNameForShort()
Accessor for the class name to use for identities when there is a single Short/short field.

Returns:
Class name of identity class

getSingleFieldIdentityClassNameForByte

java.lang.String getSingleFieldIdentityClassNameForByte()
Accessor for the class name to use for identities when there is a single Byte/byte field.

Returns:
Class name of identity class

getSingleFieldIdentityClassNameForChar

java.lang.String getSingleFieldIdentityClassNameForChar()
Accessor for the class name to use for identities when there is a single Character/char field.

Returns:
Class name of identity class

getSingleFieldIdentityClassNameForString

java.lang.String getSingleFieldIdentityClassNameForString()
Accessor for the class name to use for identities when there is a single String field.

Returns:
Class name of identity class

getSingleFieldIdentityClassNameForObject

java.lang.String getSingleFieldIdentityClassNameForObject()
Accessor for the class name to use for identities when there is a single Object field.

Returns:
Class name of identity class

getTargetClassForSingleFieldIdentity

java.lang.Class getTargetClassForSingleFieldIdentity(java.lang.Object id)
Accessor for the target class for the specified single field identity.

Parameters:
id - The identity
Returns:
The target class

getTargetClassNameForSingleFieldIdentity

java.lang.String getTargetClassNameForSingleFieldIdentity(java.lang.Object id)
Accessor for the target class name for the specified single field identity.

Parameters:
id - The identity
Returns:
The target class name

getTargetKeyForSingleFieldIdentity

java.lang.Object getTargetKeyForSingleFieldIdentity(java.lang.Object id)
Accessor for the key object for the specified single field identity.

Parameters:
id - The identity
Returns:
The key object

getKeyTypeForSingleFieldIdentityType

java.lang.Class getKeyTypeForSingleFieldIdentityType(java.lang.Class idType)
Accessor for the type of the single field application-identity key given the single field identity type.

Parameters:
idType - Single field identity type
Returns:
key type

getNewSingleFieldIdentity

java.lang.Object getNewSingleFieldIdentity(java.lang.Class idType,
                                           java.lang.Class pcType,
                                           java.lang.Object value)
Utility to create a new SingleFieldIdentity using reflection when you know the type of the PersistenceCapable, and also which SingleFieldIdentity, and the value of the key.

Parameters:
idType - Type of SingleFieldIdentity
pcType - Type of the PersistenceCapable
value - The value for the identity (the Long, or Int, or ... etc).
Returns:
The single field identity
Throws:
NucleusException - if invalid input is received

getNewApplicationIdentityObjectId

java.lang.Object getNewApplicationIdentityObjectId(ClassLoaderResolver clr,
                                                   AbstractClassMetaData acmd,
                                                   java.lang.String value)
Utility to create a new application-identity when you know the metadata for the target class, and the toString() output of the identity.

Parameters:
clr - ClassLoader resolver
acmd - MetaData for the target class
value - String form of the key
Returns:
The new identity object
Throws:
NucleusException - if invalid input is received

getNewApplicationIdentityObjectId

java.lang.Object getNewApplicationIdentityObjectId(java.lang.Object pc,
                                                   AbstractClassMetaData cmd)
Method to create a new application-identity for the passed object with the supplied MetaData.

Parameters:
pc - The persistable object
cmd - Its metadata
Returns:
The new identity object

getNewApplicationIdentityObjectId

java.lang.Object getNewApplicationIdentityObjectId(java.lang.Class cls,
                                                   java.lang.Object key)
Method to return a new object identity for the specified class, and key (possibly toString() output).

Parameters:
cls - Persistable class
key - form of the object id
Returns:
The object identity

allowPersistOfDeletedObject

boolean allowPersistOfDeletedObject()
Whether the API allows (re-)persistence of a deleted object.

Returns:
Whether you can call persist on a deleted object

allowDeleteOfNonPersistentObject

boolean allowDeleteOfNonPersistentObject()
Whether the API allows deletion of a non-persistent object.

Returns:
Whether you can call delete on an object not yet persisted

allowReadFieldOfDeletedObject

boolean allowReadFieldOfDeletedObject()
Whether the API allows reading a field of a deleted object.

Returns:
Whether you can read after deleting

clearLoadedFlagsOnDeleteObject

boolean clearLoadedFlagsOnDeleteObject()
Whether the API requires clearing of the fields of an object when it is deleted.

Returns:
Whether to clear loaded fields at delete

getDefaultCascadePersistForField

boolean getDefaultCascadePersistForField()
Method to return the default setting for cascading persist of a field

Returns:
default persist cascade setting.

getDefaultCascadeUpdateForField

boolean getDefaultCascadeUpdateForField()
Method to return the default setting for cascading update of a field

Returns:
default cascade update setting.

getDefaultCascadeDeleteForField

boolean getDefaultCascadeDeleteForField()
Method to return the default setting for cascading delete of a field

Returns:
default cascade delete setting.

getDefaultCascadeRefreshForField

boolean getDefaultCascadeRefreshForField()
Method to return the default setting for cascading refresh of a field

Returns:
default cascade refresh setting.

getDefaultFactoryProperties

java.util.Map getDefaultFactoryProperties()
Method to return a set of default properties for the factory (PMF, EMF, etc)

Returns:
The default properties (if any) for this API

getObjectId

java.lang.Object getObjectId(StateManager sm)
Accessor for the object id from the StateManager for this object.

Parameters:
sm - StateManager
Returns:
object id

getVersion

java.lang.Object getVersion(StateManager sm)
Accessor for the version from the StateManager for this object.

Parameters:
sm - StateManager

isLoaded

boolean isLoaded(StateManager sm,
                 int fieldNumber)
Accessor for whether a field is loaded for the object managed by the StateManager

Parameters:
sm - StateManager
fieldNumber - Number of the field
Returns:
Whether it is loaded

getPersistenceManager

java.lang.Object getPersistenceManager(java.lang.Object obj)
Accessor for the persistence manager for this object. The returned object will be a JDO PersistenceManager (if using JDO), or an EntityManager (if using JPA), or null if not managed.

Parameters:
obj - The object
Returns:
The persistence manager

makeFieldDirty

void makeFieldDirty(java.lang.Object obj,
                    java.lang.String fieldName)
Method to make the field dirty in the object.

Parameters:
obj - Object
fieldName - Name of the field to make dirty

getUserExceptionForException

java.lang.RuntimeException getUserExceptionForException(java.lang.String msg,
                                                        java.lang.Exception e)
Convenience method to return a user exception appropriate for this API when an unexpected exception occurs.

Parameters:
msg - The message
e - The cause (if any)
Returns:
The API exception

getDataStoreExceptionForException

java.lang.RuntimeException getDataStoreExceptionForException(java.lang.String msg,
                                                             java.lang.Exception e)
Convenience method to return a datastore exception appropriate for this API.

Parameters:
msg - The message
e - The cause (if any)
Returns:
The exception


Copyright © 2010. All Rights Reserved.