org.apache.openjpa.meta
Class ClassMetaData

java.lang.Object
  extended by org.apache.openjpa.meta.Extensions
      extended by org.apache.openjpa.meta.ClassMetaData
All Implemented Interfaces:
Serializable, Comparable, ValueListener, SourceTracker, Commentable, MetaDataContext, MetaDataModes
Direct Known Subclasses:
ClassMapping

public class ClassMetaData
extends Extensions
implements Comparable, SourceTracker, MetaDataContext, MetaDataModes, Commentable, ValueListener

Contains metadata about a persistent type. This metadata is available both at enhancement time and runtime. Note that this class employs aggressive caching, and therefore it is important to finalize the configuration of field metadatas before invoking methods that depend on that configuration, such as getPrimaryKeyFields().

Author:
Abe White
See Also:
Serialized Form

Field Summary
static int ACCESS_FIELD
          Persistent attributes are accessed via direct field access.
static int ACCESS_PROPERTY
          Persistent attributes are accessed via setters and getters.
static int ACCESS_UNKNOWN
          Unknown access type.
protected static String DEFAULT_STRING
           
static int ID_APPLICATION
          Application identity type.
static int ID_DATASTORE
          Datastore identity type.
static int ID_UNKNOWN
          Unkonwn identity type.
static String SYNTHETIC
          Value for using a synthetic detached state field, which is the default.
 
Fields inherited from class org.apache.openjpa.meta.Extensions
OPENJPA
 
Fields inherited from interface org.apache.openjpa.lib.meta.SourceTracker
SRC_ANNOTATIONS, SRC_OTHER, SRC_XML
 
Fields inherited from interface org.apache.openjpa.meta.MetaDataModes
MODE_ALL, MODE_ANN_MAPPING, MODE_MAPPING, MODE_MAPPING_INIT, MODE_META, MODE_NONE, MODE_QUERY
 
Fields inherited from interface org.apache.openjpa.lib.xml.Commentable
EMPTY_COMMENTS
 
Constructor Summary
protected ClassMetaData(Class type, MetaDataRepository repos)
          Constructor.
protected ClassMetaData(ValueMetaData owner)
          Embedded constructor.
 
Method Summary
 FetchGroup addDeclaredFetchGroup(String name)
          Adds fetch group of the given name, or returns existing instance.
 FieldMetaData addDeclaredField(String name, Class type)
          Add a new field metadata to this class.
 void addDeclaredInterface(Class iface)
          Explicitly declare the given interface among the ones this class implements.
 FieldMetaData addDefinedSuperclassField(String name, Class type, Class sup)
          Add a new defined superclass field metadata to this class.
protected  void addExtensionKeys(Collection exts)
          Add all the known extension keys to the specified collection; any implementation that utilized new extensions should override this method to include both the known extensions of its superclass as well as its own extension keys.
protected  void clearAllFieldCache()
          Clear cached field data.
protected  void clearDefinedFieldCache()
          Clear defined field data.
protected  void clearFieldCache()
          Clear cached field data.
protected  void clearSubclassCache()
          Clear cached subclass data.
 int compareTo(Object other)
           
 void copy(ClassMetaData meta)
          Copy the metadata from the given instance to this one.
 void defineSuperclassFields(boolean force)
          Incorporate superclass fields redefined in this subclass into this metadata.
 boolean equals(Object other)
           
 int getAccessType()
          The access type used by this class.
 int getColNumber()
          Return the column number in the line of the file at which this instance was parsed.
 String[] getComments()
          Return comments, or empty array if none.
 FetchGroup[] getCustomFetchGroups()
          Return all fetch groups for this type, including superclass groups.
 DataCache getDataCache()
          Return the data cache for this class, or null if it is not cachable.
 String getDataCacheName()
          The name of the datacache to use for this class.
 int getDataCacheTimeout()
          The cache timeout for this class.
 FetchGroup[] getDeclaredFetchGroups()
          Return the fetch groups declared explicitly in this type.
 FieldMetaData getDeclaredField(int index)
          Return the metadata for the persistent or transactional field with the given relative index.
 FieldMetaData getDeclaredField(String name)
          Return the metadata for the persistent or transactional field with the given name, without including superclass fields.
 FieldMetaData[] getDeclaredFields()
          Return only the fields for this class, without superclass fields.
 Class[] getDeclaredInterfaces()
          Return all explicitly declared interfaces this class implements.
 FieldMetaData[] getDeclaredUnmanagedFields()
          Return any fields that were added as non-managed.
 FieldMetaData[] getDefaultFetchGroupFields()
          Return the list of fields in the default fetch group, including superclass fields, or an empty array if none.
 FieldMetaData[] getDefinedFields()
          Returns an array of all the fields defined by this class.
 FieldMetaData[] getDefinedFieldsInListingOrder()
          Returns all fields defined by this class in the order they are listed in the metadata file.
 FieldMetaData getDefinedSuperclassField(String name)
          Return the defined superclass field with the given name, or null if none.
 Class getDescribedType()
          The persistence capable class described by this metadata.
 String getDetachedState()
          The name of the detach state field, or null if none.
 Field getDetachedStateField()
          Return the detach state field, or null if none.
 ValueMetaData getEmbeddingMetaData()
          If this metadata is for an embedded object, returning the owning value.
 ClassLoader getEnvClassLoader()
          The environmental loader used when loading this metadata.
 int getExtraFieldDataIndex(int field)
          Return the impl / intermediate field data index of the given field in the compacted array, or -1 if the field does not use extra data.
 int getExtraFieldDataLength()
          Return the number of fields that use impl or intermediate data, in order to create a compacted array for storage of said data.
 FetchGroup getFetchGroup(String name)
          Gets a named fecth group.
 FieldMetaData getField(int index)
          Return the metadata for the persistent or transactional field with the given absolute index.
 FieldMetaData getField(String name)
          Return the metadata for the persistent or transactional field with the given name.
 FieldMetaData[] getFields()
          Return all field metadatas, including superclass fields.
 FieldMetaData[] getFieldsInListingOrder()
          Returns all fields in the order they are listed in the metadata file.
 SequenceMetaData getIdentitySequenceMetaData()
          Metadata for the datastore identity sequence.
 String getIdentitySequenceName()
          The datastore identity sequence name, or null for none.
 int getIdentityStrategy()
          The strategy to use for datastore identity generation.
 int getIdentityType()
          The type of identity being used.
 String[] getInterfaceAliasedProperties(Class iface)
          Return all aliases property named for the given interface.
 Class getInterfaceImpl()
          Return the managed interface implementor if any.
 String getInterfacePropertyAlias(Class iface, String orig)
          Get local field alias for the given interface property.
 LifecycleMetaData getLifecycleMetaData()
          Information about lifecycle callbacks for this class.
 int getLineNumber()
          Return the line number of the file at which this instance was parsed.
 int getListingIndex()
          The index in which this class was listed in the metadata.
 ClassMetaData[] getMappedPCSubclassMetaDatas()
          Return all mapped subclasses.
 ClassMetaData getMappedPCSuperclassMetaData()
          Return the closest mapped superclass.
 Class getObjectIdType()
          The metadata-specified class to use for the object ID.
 Class[] getPCSubclasses()
          Return the known persistence capable subclasses of the described type, or empty array if none or if this is embedded metadata.
 ClassMetaData[] getPCSubclassMetaDatas()
          Return the metadata for the known persistence capable subclasses of the described type, or empty array if none or if this is embedded metadata.
 Class getPCSuperclass()
          The persistence capable superclass of the described type.
 ClassMetaData getPCSuperclassMetaData()
          The metadata for this class' superclass.
 FieldMetaData[] getPrimaryKeyFields()
          Return primary key fields, or empty array if none.
 MetaDataRepository getRepository()
          Return the owning repository.
 boolean getRequiresExtent()
          Whether the type requires extent management.
 int getResolve()
          The resolve mode for this metadata.
 String getResourceName()
          Return the domain-meaningful name of the resource that was loaded from this source.
 File getSourceFile()
          Return the file from which this instance was parsed.
 int getSourceMode()
          The source mode this metadata has been loaded under.
 Object getSourceScope()
          Return the domain-dependent scope of this instance within its file.
 int getSourceType()
          Return the type of source.
protected  FieldMetaData getSuperclassField(FieldMetaData supField)
          Return the superclass copy of the given field.
 String getTypeAlias()
          Returns the alias for the described type, or null if none has been set.
 FieldMetaData getVersionField()
          Return the version field for this class, if any.
 boolean hasAbstractPKField()
          Convenience method to determine if the pcType modeled by this ClassMetaData object is both abstract and declares PKFields.
 int hashCode()
           
 boolean hasPKFieldsFromAbstractClass()
          Convenience method to determine if this type is a direct decendent of an abstract type declaring PKFields.
protected  void initializeMapping()
          Initialize mapping.
 boolean isAbstract()
          Returns true if the pcType modeled by this ClassMetaData object is abstract (ie, a MappedSuperclass in JPA terms.)
 boolean isAccessibleField(String field)
          Return whether the given name represents a managed or static field of this class, including superclass fields.
 boolean isDetachable()
          Whether instances are detachable.
 boolean isEmbeddedOnly()
          Whether the type can only be used as an embedded object.
 boolean isIntercepting()
          Whether the type's fields are actively intercepted, either by redefinition or enhancement.
 boolean isManagedInterface()
          Whether the type is a managed interface.
 boolean isMapped()
          Whether this class is mapped to the datastore.
 boolean isObjectIdTypeShared()
          Whether this type uses an application identity class that is shared with other classes, and is therefore wrapped in an ObjectId.
 boolean isOpenJPAIdentity()
          Whether this type uses OpenJPA identity.
 void registerForValueUpdate(String... values)
           
 boolean removeDeclaredFetchGroup(FetchGroup fg)
          Remove a declared fetch group.
 boolean removeDeclaredField(FieldMetaData field)
          Remove the given field from management.
 boolean removeDeclaredInterface(Class iface)
          Remove the given interface from the declared list.
 boolean removeDefinedSuperclassField(FieldMetaData field)
          Remove the given field from management.
 boolean resolve(int mode)
          Resolve and validate metadata.
protected  void resolveMapping(boolean runtime)
          Resolve mapping data.
protected  void resolveMeta(boolean runtime)
          Resolve metadata.
 void setAbstract(boolean flag)
          Sets the value determining if the pcType modeled by this ClassMetaData object is abstract (ie, a MappedSuperclass in JPA terms.)
 void setAccessType(int type)
          The access type used by this class.
 void setColNumber(int colNum)
           
 void setComments(String[] comments)
          Set comments.
 void setDataCacheName(String name)
          Set the cache name for this class.
 void setDataCacheTimeout(int timeout)
          The cache timeout for this class.
protected  void setDescribedType(Class type)
          Set the class descibed by this metadata.
 void setDetachable(boolean detachable)
          Whether instances are detachable.
 void setDetachedState(String field)
          The name of the detach state field, or null if none.
 void setEmbeddedOnly(boolean embed)
          Whether the type can only be used as an embedded object.
 void setEnvClassLoader(ClassLoader loader)
          The class environmental loader used when loading this metadata.
 void setIdentitySequenceName(String seqName)
          The datastore identity sequence name, or null for none.
 void setIdentityStrategy(int strategy)
          The strategy to use for datastore identity generation.
 void setIdentityType(int type)
          The type of identity being used.
 void setIntercepting(boolean intercepting)
          Whether the type's fields are actively intercepted, either by redefinition or enhancement.
 void setInterfaceImpl(Class impl)
          Set the managed interface implementor class.
 void setInterfacePropertyAlias(Class iface, String orig, String local)
          Alias properties from the given interface during queries to the local field.
 void setIsCacheable(boolean isCacheable, boolean annotationOverride)
           Set whether or not the class represented by this ClassMetaData object should be included in the datacache.
 void setLineNumber(int lineNum)
           
 void setListingIndex(int index)
          The index in which this field was listed in the metadata.
 void setManagedInterface(boolean managedInterface)
          Whether the type is a managed interface
 void setObjectIdType(Class cls, boolean shared)
          The metadata-specified class to use for the object ID.
 void setPCSuperclass(Class pc)
          The persistence capable superclass of the described type.
 void setPCSuperclassMetaData(ClassMetaData meta)
          The metadata for this class' superclass.
 void setRequiresExtent(boolean req)
          Whether the type requires extent management.
 void setResolve(int mode)
          The resolve mode for this metadata.
 void setResolve(int mode, boolean on)
          The resolve mode for this metadata.
 void setSource(File file, int srcType)
           
 void setSourceMode(int mode)
          The source mode this metadata has been loaded under.
 void setSourceMode(int mode, boolean on)
          The source mode this metadata has been loaded under.
 void setTypeAlias(String alias)
          Sets the alias for the described type.
 String toString()
           
 Boolean usesDetachedState()
          Whether an instance of this type has detached state.
protected  void validateMapping(boolean runtime)
          Validate mapping data.
protected  void validateMeta(boolean runtime)
          Validate resolved metadata.
 void valueChanged(Value val)
          Callback used by Value objects to notify listener of change.
 
Methods inherited from class org.apache.openjpa.meta.Extensions
addExtension, addExtension, copy, getBooleanExtension, getBooleanExtension, getDoubleExtension, getDoubleExtension, getEmbeddedExtensions, getEmbeddedExtensions, getExtensionKeys, getExtensionKeys, getExtensionVendors, getIntExtension, getIntExtension, getObjectExtension, getObjectExtension, getStringExtension, getStringExtension, hasExtension, hasExtension, isEmpty, removeEmbeddedExtensions, removeEmbeddedExtensions, removeExtension, removeExtension, validateDataStoreExtensionPrefix, validateExtensionKeys
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ID_UNKNOWN

public static final int ID_UNKNOWN
Unkonwn identity type.

See Also:
Constant Field Values

ID_DATASTORE

public static final int ID_DATASTORE
Datastore identity type.

See Also:
Constant Field Values

ID_APPLICATION

public static final int ID_APPLICATION
Application identity type.

See Also:
Constant Field Values

ACCESS_UNKNOWN

public static final int ACCESS_UNKNOWN
Unknown access type.

See Also:
Constant Field Values

ACCESS_FIELD

public static final int ACCESS_FIELD
Persistent attributes are accessed via direct field access. Bit flag.

See Also:
Constant Field Values

ACCESS_PROPERTY

public static final int ACCESS_PROPERTY
Persistent attributes are accessed via setters and getters. Bit flag.

See Also:
Constant Field Values

SYNTHETIC

public static final String SYNTHETIC
Value for using a synthetic detached state field, which is the default.

See Also:
Constant Field Values

DEFAULT_STRING

protected static final String DEFAULT_STRING
See Also:
Constant Field Values
Constructor Detail

ClassMetaData

protected ClassMetaData(Class type,
                        MetaDataRepository repos)
Constructor. Supply described type and repository.


ClassMetaData

protected ClassMetaData(ValueMetaData owner)
Embedded constructor. Supply embedding value.

Method Detail

getRepository

public MetaDataRepository getRepository()
Return the owning repository.

Specified by:
getRepository in interface MetaDataContext
Specified by:
getRepository in class Extensions

getEmbeddingMetaData

public ValueMetaData getEmbeddingMetaData()
If this metadata is for an embedded object, returning the owning value.


getDescribedType

public Class getDescribedType()
The persistence capable class described by this metadata.


setDescribedType

protected void setDescribedType(Class type)
Set the class descibed by this metadata. The type may be reset when an embedded value changes its declared type.


getEnvClassLoader

public ClassLoader getEnvClassLoader()
The environmental loader used when loading this metadata. The class metadata should use this loader when loading metadata for its superclass and field types.


setEnvClassLoader

public void setEnvClassLoader(ClassLoader loader)
The class environmental loader used when loading this metadata. The class metadata should use this loader when loading metadata for its superclass and field types.


getPCSuperclass

public Class getPCSuperclass()
The persistence capable superclass of the described type.


setPCSuperclass

public void setPCSuperclass(Class pc)
The persistence capable superclass of the described type.


getPCSuperclassMetaData

public ClassMetaData getPCSuperclassMetaData()
The metadata for this class' superclass.


setPCSuperclassMetaData

public void setPCSuperclassMetaData(ClassMetaData meta)
The metadata for this class' superclass.


isMapped

public boolean isMapped()
Whether this class is mapped to the datastore. By default, only returns false if class is embedded-only, but subclasses might override to allow unmapped other types.


getMappedPCSuperclassMetaData

public ClassMetaData getMappedPCSuperclassMetaData()
Return the closest mapped superclass.


getPCSubclasses

public Class[] getPCSubclasses()
Return the known persistence capable subclasses of the described type, or empty array if none or if this is embedded metadata.


getPCSubclassMetaDatas

public ClassMetaData[] getPCSubclassMetaDatas()
Return the metadata for the known persistence capable subclasses of the described type, or empty array if none or if this is embedded metadata.


getMappedPCSubclassMetaDatas

public ClassMetaData[] getMappedPCSubclassMetaDatas()
Return all mapped subclasses.


getIdentityType

public int getIdentityType()
The type of identity being used. This will be one of: If unspecified, defaults to ID_DATASTORE if there are no primary key fields, and ID_APPLICATION otherwise.


setIdentityType

public void setIdentityType(int type)
The type of identity being used. This will be one of: If unspecified, defaults to ID_DATASTORE if there are no primary key fields, and ID_APPLICATION otherwise.


getObjectIdType

public Class getObjectIdType()
The metadata-specified class to use for the object ID.


setObjectIdType

public void setObjectIdType(Class cls,
                            boolean shared)
The metadata-specified class to use for the object ID.


isObjectIdTypeShared

public boolean isObjectIdTypeShared()
Whether this type uses an application identity class that is shared with other classes, and is therefore wrapped in an ObjectId.


isOpenJPAIdentity

public boolean isOpenJPAIdentity()
Whether this type uses OpenJPA identity.


getIdentityStrategy

public int getIdentityStrategy()
The strategy to use for datastore identity generation. One of the constants from ValueStrategies.


setIdentityStrategy

public void setIdentityStrategy(int strategy)
The strategy to use for datastore identity generation. One of the constants from ValueStrategies.


getIdentitySequenceName

public String getIdentitySequenceName()
The datastore identity sequence name, or null for none.


setIdentitySequenceName

public void setIdentitySequenceName(String seqName)
The datastore identity sequence name, or null for none.


getIdentitySequenceMetaData

public SequenceMetaData getIdentitySequenceMetaData()
Metadata for the datastore identity sequence.


getLifecycleMetaData

public LifecycleMetaData getLifecycleMetaData()
Information about lifecycle callbacks for this class.


getTypeAlias

public String getTypeAlias()
Returns the alias for the described type, or null if none has been set.

See Also:
setTypeAlias(java.lang.String)

setTypeAlias

public void setTypeAlias(String alias)
Sets the alias for the described type. The alias can be any arbitrary string that the implementation can later use to refer to the class. Note that at runtime, only the alias computed when the persistent type was enhanced is used.

Parameters:
alias - the alias name to apply to the described type

getAccessType

public int getAccessType()
The access type used by this class. Either ACCESS_FIELD or ACCESS_PROPERTY.


setAccessType

public void setAccessType(int type)
The access type used by this class. Must be either ACCESS_FIELD or ACCESS_PROPERTY.


getRequiresExtent

public boolean getRequiresExtent()
Whether the type requires extent management.


setRequiresExtent

public void setRequiresExtent(boolean req)
Whether the type requires extent management.


isEmbeddedOnly

public boolean isEmbeddedOnly()
Whether the type can only be used as an embedded object.


setEmbeddedOnly

public void setEmbeddedOnly(boolean embed)
Whether the type can only be used as an embedded object.


isIntercepting

public boolean isIntercepting()
Whether the type's fields are actively intercepted, either by redefinition or enhancement.


setIntercepting

public void setIntercepting(boolean intercepting)
Whether the type's fields are actively intercepted, either by redefinition or enhancement.


isManagedInterface

public boolean isManagedInterface()
Whether the type is a managed interface.


setManagedInterface

public void setManagedInterface(boolean managedInterface)
Whether the type is a managed interface


getInterfaceImpl

public Class getInterfaceImpl()
Return the managed interface implementor if any.


setInterfaceImpl

public void setInterfaceImpl(Class impl)
Set the managed interface implementor class.


getDeclaredInterfaces

public Class[] getDeclaredInterfaces()
Return all explicitly declared interfaces this class implements.


addDeclaredInterface

public void addDeclaredInterface(Class iface)
Explicitly declare the given interface among the ones this class implements.


removeDeclaredInterface

public boolean removeDeclaredInterface(Class iface)
Remove the given interface from the declared list.


setInterfacePropertyAlias

public void setInterfacePropertyAlias(Class iface,
                                      String orig,
                                      String local)
Alias properties from the given interface during queries to the local field.


getInterfacePropertyAlias

public String getInterfacePropertyAlias(Class iface,
                                        String orig)
Get local field alias for the given interface property.


getInterfaceAliasedProperties

public String[] getInterfaceAliasedProperties(Class iface)
Return all aliases property named for the given interface.


getExtraFieldDataLength

public int getExtraFieldDataLength()
Return the number of fields that use impl or intermediate data, in order to create a compacted array for storage of said data.


getExtraFieldDataIndex

public int getExtraFieldDataIndex(int field)
Return the impl / intermediate field data index of the given field in the compacted array, or -1 if the field does not use extra data.

See Also:
getExtraFieldDataLength()

isAccessibleField

public boolean isAccessibleField(String field)
Return whether the given name represents a managed or static field of this class, including superclass fields.


getFields

public FieldMetaData[] getFields()
Return all field metadatas, including superclass fields.


getSuperclassField

protected FieldMetaData getSuperclassField(FieldMetaData supField)
Return the superclass copy of the given field.


getDeclaredFields

public FieldMetaData[] getDeclaredFields()
Return only the fields for this class, without superclass fields.


getPrimaryKeyFields

public FieldMetaData[] getPrimaryKeyFields()
Return primary key fields, or empty array if none. The order in which the keys are returned will be the order in which the fields are declared, starting at the least-derived superclass and ending with the primary key fields of the most-derived subclass.


getDefaultFetchGroupFields

public FieldMetaData[] getDefaultFetchGroupFields()
Return the list of fields in the default fetch group, including superclass fields, or an empty array if none.


getVersionField

public FieldMetaData getVersionField()
Return the version field for this class, if any.


getField

public FieldMetaData getField(int index)
Return the metadata for the persistent or transactional field with the given absolute index.

Returns:
the field's metadata, or null if not found

getDeclaredField

public FieldMetaData getDeclaredField(int index)
Return the metadata for the persistent or transactional field with the given relative index.

Returns:
the field's metadata, or null if not found

getField

public FieldMetaData getField(String name)
Return the metadata for the persistent or transactional field with the given name.

Returns:
the field's metadata, or null if not found

getDeclaredField

public FieldMetaData getDeclaredField(String name)
Return the metadata for the persistent or transactional field with the given name, without including superclass fields.

Returns:
the field's metadata, or null if not found

getDeclaredUnmanagedFields

public FieldMetaData[] getDeclaredUnmanagedFields()
Return any fields that were added as non-managed. All other methods to get fields return only those that are managed.


addDeclaredField

public FieldMetaData addDeclaredField(String name,
                                      Class type)
Add a new field metadata to this class.


removeDeclaredField

public boolean removeDeclaredField(FieldMetaData field)
Remove the given field from management.

Returns:
true if the field was removed, false otherwise

getDefinedSuperclassField

public FieldMetaData getDefinedSuperclassField(String name)
Return the defined superclass field with the given name, or null if none.


addDefinedSuperclassField

public FieldMetaData addDefinedSuperclassField(String name,
                                               Class type,
                                               Class sup)
Add a new defined superclass field metadata to this class.


removeDefinedSuperclassField

public boolean removeDefinedSuperclassField(FieldMetaData field)
Remove the given field from management.

Returns:
true if the field was removed, false otherwise

defineSuperclassFields

public void defineSuperclassFields(boolean force)
Incorporate superclass fields redefined in this subclass into this metadata. This method is generally called after metadata is resolved and mapping information is loaded, but before mapping resolve.

Parameters:
force - whether to force re-mapping of even mapped superclass fields

getDefinedFields

public FieldMetaData[] getDefinedFields()
Returns an array of all the fields defined by this class. This includes mapped declared fields and any concrete mapping of unmapped superclass fields performed by this class.


getFieldsInListingOrder

public FieldMetaData[] getFieldsInListingOrder()
Returns all fields in the order they are listed in the metadata file. Unlisted fields are placed after listed ones.


getDefinedFieldsInListingOrder

public FieldMetaData[] getDefinedFieldsInListingOrder()
Returns all fields defined by this class in the order they are listed in the metadata file. Unlisted fields are placed after listed ones. This array includes declared transactional and unmanaged fields.


getDataCacheName

public String getDataCacheName()
The name of the datacache to use for this class. If this class is not eligible for caching based its annotation or the cache configuration null will be returned.

Returns:
The cache name, or null if this type should not be cached.

setDataCacheName

public void setDataCacheName(String name)
Set the cache name for this class. Set to null to disable caching.


getDataCacheTimeout

public int getDataCacheTimeout()
The cache timeout for this class. -1 indicates no timeout.


setDataCacheTimeout

public void setDataCacheTimeout(int timeout)
The cache timeout for this class. -1 indicates no timeout.


getDataCache

public DataCache getDataCache()
Return the data cache for this class, or null if it is not cachable.


isDetachable

public boolean isDetachable()
Whether instances are detachable.


setDetachable

public void setDetachable(boolean detachable)
Whether instances are detachable.


getDetachedState

public String getDetachedState()
The name of the detach state field, or null if none.


setDetachedState

public void setDetachedState(String field)
The name of the detach state field, or null if none.


getDetachedStateField

public Field getDetachedStateField()
Return the detach state field, or null if none.


usesDetachedState

public Boolean usesDetachedState()
Whether an instance of this type has detached state.

Returns:
true if a detached instance must have detached state, false if it does not, and null if it may use a manually-constructed instance without detached state

clearAllFieldCache

protected void clearAllFieldCache()
Clear cached field data.


clearDefinedFieldCache

protected void clearDefinedFieldCache()
Clear defined field data.


clearFieldCache

protected void clearFieldCache()
Clear cached field data.


clearSubclassCache

protected void clearSubclassCache()
Clear cached subclass data.


hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object other)
Overrides:
equals in class Object

compareTo

public int compareTo(Object other)
Specified by:
compareTo in interface Comparable

toString

public String toString()
Overrides:
toString in class Object

getResolve

public int getResolve()
The resolve mode for this metadata.


setResolve

public void setResolve(int mode)
The resolve mode for this metadata.


setResolve

public void setResolve(int mode,
                       boolean on)
The resolve mode for this metadata.


resolve

public boolean resolve(int mode)
Resolve and validate metadata. Return true if already resolved.


resolveMeta

protected void resolveMeta(boolean runtime)
Resolve metadata.


validateMeta

protected void validateMeta(boolean runtime)
Validate resolved metadata.


resolveMapping

protected void resolveMapping(boolean runtime)
Resolve mapping data. Logs resolve message and resolves super by default.


validateMapping

protected void validateMapping(boolean runtime)
Validate mapping data.


initializeMapping

protected void initializeMapping()
Initialize mapping. Logs init message by default.


getDeclaredFetchGroups

public FetchGroup[] getDeclaredFetchGroups()
Return the fetch groups declared explicitly in this type.


getCustomFetchGroups

public FetchGroup[] getCustomFetchGroups()
Return all fetch groups for this type, including superclass groups.


getFetchGroup

public FetchGroup getFetchGroup(String name)
Gets a named fecth group. If not available in this receiver then looks up the inheritence hierarchy.

Parameters:
name - name of a fetch group.
Returns:
an existing fecth group of the given name if known to this receiver or any of its superclasses. Otherwise null.

addDeclaredFetchGroup

public FetchGroup addDeclaredFetchGroup(String name)
Adds fetch group of the given name, or returns existing instance.

Parameters:
name - a non-null, non-empty name. Must be unique within this receiver's scope. The super class may have a group with the same name.

removeDeclaredFetchGroup

public boolean removeDeclaredFetchGroup(FetchGroup fg)
Remove a declared fetch group.


getSourceFile

public File getSourceFile()
Description copied from interface: SourceTracker
Return the file from which this instance was parsed.

Specified by:
getSourceFile in interface SourceTracker

getSourceScope

public Object getSourceScope()
Description copied from interface: SourceTracker
Return the domain-dependent scope of this instance within its file.

Specified by:
getSourceScope in interface SourceTracker

getSourceType

public int getSourceType()
Description copied from interface: SourceTracker
Return the type of source.

Specified by:
getSourceType in interface SourceTracker

setSource

public void setSource(File file,
                      int srcType)

getResourceName

public String getResourceName()
Description copied from interface: SourceTracker
Return the domain-meaningful name of the resource that was loaded from this source. I.e., if we had loaded the source for a Java class, this would return the name of the class.

Specified by:
getResourceName in interface SourceTracker

getLineNumber

public int getLineNumber()
Description copied from interface: SourceTracker
Return the line number of the file at which this instance was parsed.

Specified by:
getLineNumber in interface SourceTracker

setLineNumber

public void setLineNumber(int lineNum)

getColNumber

public int getColNumber()
Description copied from interface: SourceTracker
Return the column number in the line of the file at which this instance was parsed.

Specified by:
getColNumber in interface SourceTracker

setColNumber

public void setColNumber(int colNum)

getSourceMode

public int getSourceMode()
The source mode this metadata has been loaded under.


setSourceMode

public void setSourceMode(int mode)
The source mode this metadata has been loaded under.


setSourceMode

public void setSourceMode(int mode,
                          boolean on)
The source mode this metadata has been loaded under.


getListingIndex

public int getListingIndex()
The index in which this class was listed in the metadata. Defaults to -1 if this class was not listed in the metadata.


setListingIndex

public void setListingIndex(int index)
The index in which this field was listed in the metadata. Defaults to -1 if this class was not listed in the metadata.


getComments

public String[] getComments()
Description copied from interface: Commentable
Return comments, or empty array if none.

Specified by:
getComments in interface Commentable

setComments

public void setComments(String[] comments)
Description copied from interface: Commentable
Set comments.

Specified by:
setComments in interface Commentable

copy

public void copy(ClassMetaData meta)
Copy the metadata from the given instance to this one. Do not copy mapping information.


addExtensionKeys

protected void addExtensionKeys(Collection exts)
Description copied from class: Extensions
Add all the known extension keys to the specified collection; any implementation that utilized new extensions should override this method to include both the known extensions of its superclass as well as its own extension keys.

Overrides:
addExtensionKeys in class Extensions

registerForValueUpdate

public void registerForValueUpdate(String... values)

valueChanged

public void valueChanged(Value val)
Description copied from interface: ValueListener
Callback used by Value objects to notify listener of change.

Specified by:
valueChanged in interface ValueListener

setIsCacheable

public void setIsCacheable(boolean isCacheable,
                           boolean annotationOverride)

Set whether or not the class represented by this ClassMetaData object should be included in the datacache. The arguments provided are *hints* as to whether the class should be included in the datacache, and can be overridden by the configuration set in openjpa.Datacache.

Rules for this determination are:

  1. If the class shows up in the list of excluded types, it does not get cached, period.
  2. If the class does not show up in the excluded types, but the included types field is set (ie, has at least one class), then:
    1. If the class is listed in the include list, then it gets cached
    2. If the class is set as cacheable by the @Datacache annotation, it gets cached
    3. If neither a or b are true, then the class does not get cached
  3. If neither the include or exclude lists are defined, then go along with the value passed into the argument, which is either the default value (true) or whatever was set with the @Datacache annotation

Parameters:
isCacheable - Hint whether this class should be included in the datacache. Default behavior is yes, though the
annotationOverride - Whether this hint originated from the @Datacache annotation or whether this is the default "yes" hint. The origination of the hint influences the decision making process in rule #2b.

isAbstract

public boolean isAbstract()
Returns true if the pcType modeled by this ClassMetaData object is abstract (ie, a MappedSuperclass in JPA terms.)

Returns:

setAbstract

public void setAbstract(boolean flag)
Sets the value determining if the pcType modeled by this ClassMetaData object is abstract (ie, a MappedSuperclass in JPA terms.)


hasAbstractPKField

public boolean hasAbstractPKField()
Convenience method to determine if the pcType modeled by this ClassMetaData object is both abstract and declares PKFields. This method is used by the PCEnhancer to determine if special handling is required.

Returns:

hasPKFieldsFromAbstractClass

public boolean hasPKFieldsFromAbstractClass()
Convenience method to determine if this type is a direct decendent of an abstract type declaring PKFields. Returns true if there are no pcTypes mapped to a table between this type and an abstract pcType declaring PKFields. Returns false if there no such abstract pcTypes in the inheritance hierarchy or if there are any pcTypes mapped to tables in between the type represented by this ClassMetaData object and the abstract pcType declaring PKFields.

Returns:


Copyright © 2006-2010 Apache Software Foundation. All Rights Reserved.