public class ClassMetaData extends Extensions implements Comparable<ClassMetaData>, SourceTracker, MetaDataContext, MetaDataModes, Commentable, ValueListener
getPrimaryKeyFields()
.Modifier and Type | Field and Description |
---|---|
static int |
ACCESS_EXPLICIT
Persistent class has explicitly defined an access type.
|
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
Unknown identity type.
|
static String |
SYNTHETIC
Value for using a synthetic detached state field, which is the default.
|
OPENJPA
SRC_ANNOTATIONS, SRC_OTHER, SRC_XML
MODE_ALL, MODE_ANN_MAPPING, MODE_MAPPING, MODE_MAPPING_INIT, MODE_META, MODE_NONE, MODE_QUERY
EMPTY_COMMENTS
Modifier | Constructor and Description |
---|---|
protected |
ClassMetaData(Class<?> type,
MetaDataRepository repos)
Constructor.
|
protected |
ClassMetaData(ValueMetaData owner)
Embedded constructor.
|
Modifier and Type | Method and Description |
---|---|
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(ClassMetaData 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.
|
Boolean |
getCacheEnabled()
Returns tri-state status on whether this class has been enabled for caching.
|
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 but excluding the standard groups
such as "default" or "all".
|
DataCache |
getDataCache()
Return the data cache for this class, or null if it is not cachable.
|
boolean |
getDataCacheEnabled()
Affirms true if this receiver is annotated with @DataCache and is not disabled.
|
String |
getDataCacheName()
The name of the data cache that stores the managed instance of this class, by default.
|
int |
getDataCacheTimeout()
The cache timeout for this class. -1 indicates no timeout.
|
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.
|
String[] |
getDeclaredFieldNames()
Utility method to get names of all declared fields excluding the
superclasses' sorted in lexical order.
|
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 |
getDescribedTypeString()
The persistence capable stringified 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 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 fetch 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.
|
String[] |
getFieldNames()
Utility method to get names of all fields including the superclasses'
sorted in lexical order.
|
FieldMetaData[] |
getFields()
Return all field metadata, including superclass fields.
|
FieldMetaData[] |
getFieldsInListingOrder()
Returns all fields in the order they are listed in the metadata
file.
|
Class<?> |
getIdClass()
The class specified with the @IdClass annotation if used
|
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.
|
FieldMetaData[] |
getLrsFields()
Return all large result set fields.
|
ClassMetaData[] |
getMappedPCSubclassMetaDatas()
Return all mapped subclasses.
|
ClassMetaData |
getMappedPCSuperclassMetaData()
Return the closest mapped superclass.
|
List<FieldMetaData> |
getMappyedByIdFields() |
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.
|
int[] |
getPkAndNonPersistentManagedFmdIndexes() |
FieldMetaData[] |
getPrimaryKeyFields()
Return primary key fields, or empty array if none.
|
FieldMetaData[] |
getProxyFields()
Return all fields that are types that need to be wrappered by a proxy.
|
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.
|
String |
getSourceName() |
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. |
boolean |
getUseSchemaElement()
Set whether to include schema name in generated class files
|
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 |
hasInverseManagedFields() |
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() |
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 |
isEmbeddable() |
boolean |
isEmbeddedOnly()
Whether the type can only be used as an embedded object.
|
boolean |
isExplicitAccess()
Affirms if access style is explicitly defined.
|
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 |
isMixedAccess()
Affirms if attributes of this class use mixed access types.
|
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) |
void |
setAccessType(int type)
Sets the access type.
|
void |
setCacheEnabled(boolean enabled)
Sets the eligibility status of this class for cache.
|
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. -1 indicates no timeout.
|
protected void |
setDescribedType(Class<?> type)
Set the class described 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 |
setEmbeddable() |
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 |
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,
String srcName) |
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.
|
void |
setUseSchemaElement(boolean useSchemaElement)
Get whether to include schema name in generated class files
|
String |
toString() |
boolean |
useIdClassFromParent()
Return true if this class uses IdClass derived from idClass of the
parent entity which annotated as id in the child class.
|
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. |
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
public static final int ID_UNKNOWN
public static final int ID_DATASTORE
public static final int ID_APPLICATION
public static final int ACCESS_UNKNOWN
public static final int ACCESS_FIELD
public static final int ACCESS_PROPERTY
public static final int ACCESS_EXPLICIT
public static final String SYNTHETIC
protected static final String DEFAULT_STRING
protected ClassMetaData(Class<?> type, MetaDataRepository repos)
protected ClassMetaData(ValueMetaData owner)
public MetaDataRepository getRepository()
getRepository
in interface MetaDataContext
getRepository
in class Extensions
public ValueMetaData getEmbeddingMetaData()
public Class<?> getDescribedType()
public String getDescribedTypeString()
protected void setDescribedType(Class<?> type)
public ClassLoader getEnvClassLoader()
public void setEnvClassLoader(ClassLoader loader)
public Class<?> getPCSuperclass()
public void setPCSuperclass(Class<?> pc)
public ClassMetaData getPCSuperclassMetaData()
public void setPCSuperclassMetaData(ClassMetaData meta)
public boolean isMapped()
public ClassMetaData getMappedPCSuperclassMetaData()
public Class<?>[] getPCSubclasses()
public ClassMetaData[] getPCSubclassMetaDatas()
public ClassMetaData[] getMappedPCSubclassMetaDatas()
public int getIdentityType()
ID_UNKNOWN
: unknown identity typeID_DATASTORE
: identity managed by the data store and
independent of the fields of the instanceID_APPLICATION
: identity managed by the application and
defined by one or more fields of the instanceID_DATASTORE
if there are no
primary key fields, and ID_APPLICATION
otherwise.public void setIdentityType(int type)
ID_UNKNOWN
: unknown identity typeID_DATASTORE
: identity managed by the data store and
independent of the fields of the instanceID_APPLICATION
: identity managed by the application and
defined by one or more fields of the instanceID_DATASTORE
if there are no
primary key fields, and ID_APPLICATION
otherwise.public Class<?> getObjectIdType()
public void setObjectIdType(Class<?> cls, boolean shared)
public boolean isObjectIdTypeShared()
ObjectId
.public boolean isOpenJPAIdentity()
public int getIdentityStrategy()
ValueStrategies
.public void setIdentityStrategy(int strategy)
ValueStrategies
.public String getIdentitySequenceName()
public void setIdentitySequenceName(String seqName)
public SequenceMetaData getIdentitySequenceMetaData()
public LifecycleMetaData getLifecycleMetaData()
public String getTypeAlias()
null
if none
has been set.setTypeAlias(java.lang.String)
public void setTypeAlias(String alias)
alias
- the alias name to apply to the described typepublic int getAccessType()
public void setAccessType(int type)
public boolean isExplicitAccess()
public boolean isMixedAccess()
public boolean getRequiresExtent()
public void setRequiresExtent(boolean req)
public boolean isEmbeddedOnly()
public void setEmbeddedOnly(boolean embed)
public boolean isEmbeddable()
public void setEmbeddable()
public boolean isIntercepting()
public void setIntercepting(boolean intercepting)
public boolean isManagedInterface()
public void setManagedInterface(boolean managedInterface)
public Class<?> getInterfaceImpl()
public void setInterfaceImpl(Class<?> impl)
public Class<?>[] getDeclaredInterfaces()
public void addDeclaredInterface(Class<?> iface)
public boolean removeDeclaredInterface(Class<?> iface)
public void setInterfacePropertyAlias(Class<?> iface, String orig, String local)
public String getInterfacePropertyAlias(Class<?> iface, String orig)
public String[] getInterfaceAliasedProperties(Class<?> iface)
public int getExtraFieldDataLength()
public int getExtraFieldDataIndex(int field)
getExtraFieldDataLength()
public boolean isAccessibleField(String field)
public FieldMetaData[] getProxyFields()
public FieldMetaData[] getLrsFields()
public FieldMetaData[] getFields()
protected FieldMetaData getSuperclassField(FieldMetaData supField)
public FieldMetaData[] getDeclaredFields()
public FieldMetaData[] getPrimaryKeyFields()
public FieldMetaData[] getDefaultFetchGroupFields()
public FieldMetaData getVersionField()
public FieldMetaData getField(int index)
public FieldMetaData getDeclaredField(int index)
public FieldMetaData getField(String name)
public FieldMetaData getDeclaredField(String name)
public FieldMetaData[] getDeclaredUnmanagedFields()
public FieldMetaData addDeclaredField(String name, Class<?> type)
public boolean removeDeclaredField(FieldMetaData field)
public FieldMetaData getDefinedSuperclassField(String name)
public FieldMetaData addDefinedSuperclassField(String name, Class<?> type, Class<?> sup)
public boolean removeDefinedSuperclassField(FieldMetaData field)
public void defineSuperclassFields(boolean force)
force
- whether to force re-mapping of even mapped superclass fieldspublic FieldMetaData[] getDefinedFields()
public FieldMetaData[] getFieldsInListingOrder()
public FieldMetaData[] getDefinedFieldsInListingOrder()
public String getDataCacheName()
public void setDataCacheName(String name)
name
- can be null
to disable cache.public boolean getDataCacheEnabled()
public int getDataCacheTimeout()
public void setDataCacheTimeout(int timeout)
public DataCache getDataCache()
public boolean isDetachable()
public void setDetachable(boolean detachable)
public String getDetachedState()
public void setDetachedState(String field)
public Field getDetachedStateField()
public Boolean usesDetachedState()
protected void clearAllFieldCache()
protected void clearDefinedFieldCache()
protected void clearFieldCache()
protected void clearSubclassCache()
public int compareTo(ClassMetaData other)
compareTo
in interface Comparable<ClassMetaData>
public int getResolve()
public void setResolve(int mode)
public void setResolve(int mode, boolean on)
public boolean resolve(int mode)
protected void resolveMeta(boolean runtime)
protected void validateMeta(boolean runtime)
protected void resolveMapping(boolean runtime)
protected void validateMapping(boolean runtime)
protected void initializeMapping()
public boolean useIdClassFromParent()
public FetchGroup[] getDeclaredFetchGroups()
public FetchGroup[] getCustomFetchGroups()
public FetchGroup getFetchGroup(String name)
name
- name of a fetch group.public FetchGroup addDeclaredFetchGroup(String name)
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.public boolean removeDeclaredFetchGroup(FetchGroup fg)
public File getSourceFile()
SourceTracker
getSourceFile
in interface SourceTracker
public Object getSourceScope()
SourceTracker
getSourceScope
in interface SourceTracker
public int getSourceType()
SourceTracker
getSourceType
in interface SourceTracker
public String getResourceName()
SourceTracker
getResourceName
in interface SourceTracker
public int getLineNumber()
SourceTracker
getLineNumber
in interface SourceTracker
public void setLineNumber(int lineNum)
public int getColNumber()
SourceTracker
getColNumber
in interface SourceTracker
public void setColNumber(int colNum)
public int getSourceMode()
public void setSourceMode(int mode)
public void setSourceMode(int mode, boolean on)
public int getListingIndex()
-1
if this class was not listed in the metadata.public void setListingIndex(int index)
-1
if this class was not listed in the metadata.public String[] getComments()
Commentable
getComments
in interface Commentable
public void setComments(String[] comments)
Commentable
setComments
in interface Commentable
public void copy(ClassMetaData meta)
protected void addExtensionKeys(Collection exts)
Extensions
addExtensionKeys
in class Extensions
public void registerForValueUpdate(String... values)
public void valueChanged(Value val)
ValueListener
Value
objects to notify listener of change.valueChanged
in interface ValueListener
public String[] getFieldNames()
public String[] getDeclaredFieldNames()
public boolean isAbstract()
public void setAbstract(boolean flag)
public boolean hasAbstractPKField()
public boolean hasPKFieldsFromAbstractClass()
public void setCacheEnabled(boolean enabled)
public Boolean getCacheEnabled()
public String getSourceName()
public int[] getPkAndNonPersistentManagedFmdIndexes()
public boolean hasInverseManagedFields()
public List<FieldMetaData> getMappyedByIdFields()
public boolean getUseSchemaElement()
public void setUseSchemaElement(boolean useSchemaElement)
public Class<?> getIdClass()
Copyright © 2006–2018 Apache Software Foundation. All rights reserved.