|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.openjpa.meta.Extensions org.apache.openjpa.meta.ClassMetaData
public class ClassMetaData
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()
.
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 java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
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 String SYNTHETIC
protected static final String DEFAULT_STRING
Constructor Detail |
---|
protected ClassMetaData(Class type, MetaDataRepository repos)
protected ClassMetaData(ValueMetaData owner)
Method Detail |
---|
public MetaDataRepository getRepository()
getRepository
in interface MetaDataContext
getRepository
in class Extensions
public ValueMetaData getEmbeddingMetaData()
public Class getDescribedType()
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()
ACCESS_FIELD
or ACCESS_PROPERTY
.
public void setAccessType(int type)
ACCESS_FIELD
or ACCESS_PROPERTY
.
public boolean getRequiresExtent()
public void setRequiresExtent(boolean req)
public boolean isEmbeddedOnly()
public void setEmbeddedOnly(boolean embed)
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[] 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)
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 hashCode()
hashCode
in class Object
public boolean equals(Object other)
equals
in class Object
public int compareTo(Object other)
compareTo
in interface Comparable
public String toString()
toString
in class Object
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 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 void setSource(File file, int srcType)
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 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:
isCacheable
- Hint whether this class should be included in the datacache. Default behavior is yes, though theannotationOverride
- 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.public boolean isAbstract()
public void setAbstract(boolean flag)
public boolean hasAbstractPKField()
public boolean hasPKFieldsFromAbstractClass()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |