org.datanucleus.metadata
Class ClassMetaData

java.lang.Object
  extended by org.datanucleus.metadata.MetaData
      extended by org.datanucleus.metadata.AbstractClassMetaData
          extended by org.datanucleus.metadata.ClassMetaData
All Implemented Interfaces:
java.io.Serializable

public class ClassMetaData
extends AbstractClassMetaData

Representation of the MetaData of a class. Extends the abstract definition to include implementations, fields, embedded-only tags. Has a parent PackageMetaData that can contain the metadata for several classes.

Lifecycle state

This object supports 3 lifecycle states. The first is the raw constructed object which represents pure MetaData (maybe from a MetaData file). The second is a "populated" object which represents MetaData for a Class with the metadata aligned to be appropriate for that Class. The third is "initialised" once the internal arrays are created. This object, once populated, will represent ALL fields in the class (including static, final and transient fields).

Fields/Properties

This object keeps a list of FieldMetaData/PropertyMetaData objects for the fields of this class. In addition it has an array of FieldMetaData objects representing those that are actually managed by JDO ("managedFields"). This second set does not contain things like static, final or transient fields since JDO doesn't support those yet.

Fields are of 2 types. The first are normal fields of this class. These have their own "relative" field number, relative to this class. The second type are "overriding" fields which override the baseline field in a superclass. These fields have no "relative" field number since they are relative to this class (and such a relative field number would make no sense). Fields are all added through addField() during the parse process, and are updated during the populate/initialise process to define their relative field numbers. Please refer to FieldMetaData for more details of fields.

Numbering of fields

Fields of the class are numbered in 2 ways. The first way is the numbering within a class. In a class, the field 'id's will start at 0. If a class is inherited, it will also have a second numbering for its fields - the "absolute" numbering. With "absolute" numbering, the fields start at the first field in the root superclass which has absolute number 0, and they are numbered from there, navigating down the hierarchy. In terms of what is stored in the records, the FieldMetaData stores fieldId as the first method (relative to the class it is in). The "absolute" numbering is always derived from this and the inheritance hierarchy.

See Also:
Serialized Form

Field Summary
protected  java.util.List<ImplementsMetaData> implementations
          List of implements.
protected  ImplementsMetaData[] implementsMetaData
          ImplementsMetaData
protected  boolean isAbstract
          is the persistable class abstract.
 
Fields inherited from class org.datanucleus.metadata.AbstractClassMetaData
allMemberPositions, cacheable, catalog, detachable, dfgMemberFlags, dfgMemberPositions, embeddedOnly, entityName, excludeDefaultListeners, excludeSuperClassListeners, fetchGroupMetaData, fetchGroupMetaDataByName, fetchGroupMetaWithPostLoad, fetchGroups, foreignKeyMetaData, foreignKeys, fullName, GENERATED_PK_SUFFIX, identityMetaData, identitySpecified, identityType, implementationOfPersistentDefinition, indexes, indexMetaData, inheritanceMetaData, joinMetaData, joins, listeners, LOCALISER_API, managedMembers, memberCount, memberPositionsByName, members, metaDataComplete, name, nonPkMemberFlags, nonPkMemberPositions, noOfInheritedManagedMembers, objectidClass, overriddenMembers, pcSuperclassMetaData, persistenceCapableSuperclass, persistenceModifier, persistentInterfaceImplNeedingTableFromSubclass, persistentInterfaceImplNeedingTableFromSuperclass, pkMemberPositions, primaryKeyMetaData, queries, queryResultMetaData, relationPositions, requiresExtent, schema, scoMutableMemberFlags, scoMutableMemberPositions, scoNonContainerMemberPositions, secondClassContainerMemberPositions, serializeRead, table, uniqueConstraints, uniqueMetaData, unmappedColumns, usesSingleFieldIdentityClass, versionMetaData
 
Fields inherited from class org.datanucleus.metadata.MetaData
extensions, LOCALISER, METADATA_CREATED_STATE, METADATA_INITIALISED_STATE, METADATA_POPULATED_STATE, METADATA_USED_STATE, metaDataState, parent, VENDOR_NAME, VENDOR_NAME_OLD
 
Constructor Summary
ClassMetaData(ClassMetaData cmd, java.lang.String implClassName)
          Constructor for creating the ClassMetaData for an implementation of a "persistent-abstract-class".
ClassMetaData(InterfaceMetaData imd, java.lang.String implClassName, boolean copyFields)
          Constructor for creating the ClassMetaData for an implementation of a "persistent-interface".
ClassMetaData(PackageMetaData parent, java.lang.String name)
          Constructor.
 
Method Summary
 void addImplements(ImplementsMetaData implmd)
          Method to add an implements to this class.
protected  void addMetaDataForMembersNotInMetaData(java.lang.Class cls, MetaDataManager mmgr)
          Add MetaData of fields/properties not declared in MetaData.
 ImplementsMetaData[] getImplementsMetaData()
          Accessor for the implements MetaData
 boolean implementsInterface(java.lang.String interfaceName)
          Convenience accessor for whether this class implements a specified interface
 void initialise(ClassLoaderResolver clr, MetaDataManager mmgr)
          Method to initialise the object, creating internal convenience arrays.
 boolean isAbstract()
          Whether the PersistenceCapable class is abstract.
protected  AbstractMemberMetaData newDefaultedProperty(java.lang.String name)
          Utility to add a defaulted FieldMetaData to the class.
 void populate(ClassLoaderResolver clr, java.lang.ClassLoader primary, MetaDataManager mmgr)
          Method to provide the details of the class being represented by this MetaData.
protected  void populateMemberMetaData(ClassLoaderResolver clr, java.lang.Class cls, boolean pkMembers, java.lang.ClassLoader primary, MetaDataManager mmgr)
          Populate MetaData for all members.
 java.lang.String toString(java.lang.String prefix, java.lang.String indent)
          Returns a string representation of the object.
 
Methods inherited from class org.datanucleus.metadata.AbstractClassMetaData
addFetchGroup, addForeignKey, addIndex, addJoin, addListener, addMember, addQuery, addQueryResultMetaData, addUniqueConstraint, addUnmappedColumn, applyDefaultDiscriminatorValueWhenNotSpecified, checkInitialised, checkPopulated, copyMembersFromInterface, determineIdentity, determineInheritanceMetaData, determineObjectIdClass, determineSuperClassName, excludeDefaultListeners, excludeSuperClassListeners, getAbsoluteMemberPositionForRelativePosition, getAbsolutePositionOfMember, getAbsolutePositionOfMember, getAllMemberPositions, getBaseAbstractClassMetaData, getBaseIdentityMetaData, getBaseInheritanceStrategy, getBasicMemberPositions, getBidirectionalRelationMemberPositions, getCatalog, getDFGMemberFlags, getDFGMemberPositions, getDiscriminatorMetaData, getDiscriminatorMetaDataForTable, getDiscriminatorStrategy, getDiscriminatorStrategyForTable, getEntityName, getFetchGroupMetaData, getFetchGroupMetaData, getFetchGroupMetaData, getForeignKeyMetaData, getFullClassName, getIdentityMetaData, getIdentityType, getIndexMetaData, getInheritanceMetaData, getJoinMetaData, getListenerForClass, getListeners, getManagedMembers, getMemberBeingOverridden, getMemberCount, getMetaDataForManagedMemberAtAbsolutePosition, getMetaDataForManagedMemberAtAbsolutePositionInternal, getMetaDataForManagedMemberAtPosition, getMetaDataForMember, getMetaDataForMemberAtRelativePosition, getMultivaluedMemberPositions, getName, getNonPKMemberFlags, getNonPKMemberPositions, getNoOfInheritedManagedMembers, getNoOfManagedMembers, getNoOfMembers, getNoOfOverriddenMembers, getNoOfPrimaryKeyMembers, getNoOfQueries, getObjectidClass, getOverriddenMember, getOverriddenMember, getOverriddenMembers, getPackageMetaData, getPackageName, getPersistenceCapableSuperclass, getPersistenceModifier, getPKMemberPositions, getPrimaryKeyMemberNames, getPrimaryKeyMetaData, getQueries, getQueryResultMetaData, getRelationMemberPositions, getRelativePositionOfMember, getSchema, getSCOContainerMemberPositions, getSCOMutableMemberFlags, getSCOMutableMemberPositions, getSCONonContainerMemberPositions, getSuperAbstractClassMetaData, getTable, getUniqueMetaData, getUnmappedColumns, getVersionMetaData, getVersionMetaDataForTable, hasDiscriminatorStrategy, hasFetchGroupWithPostLoad, hasMember, hasRelations, hasVersionStrategy, inheritIdentity, initialiseMemberPositionInformation, isCacheable, isDetachable, isEmbeddedOnly, isExcludeDefaultListeners, isExcludeSuperClassListeners, isImplementationOfPersistentDefinition, isMetaDataComplete, isRequiresExtent, isSameOrAncestorOf, isSerializeRead, loadClass, newFetchGroupMetaData, newFieldMetadata, newForeignKeyMetadata, newIdentityMetadata, newIndexMetadata, newInheritanceMetadata, newJoinMetaData, newPrimaryKeyMetadata, newPropertyMetadata, newQueryMetadata, newUniqueMetadata, newUnmappedColumnMetaData, newVersionMetadata, setCacheable, setCacheable, setCatalog, setDetachable, setDetachable, setEmbeddedOnly, setEmbeddedOnly, setEntityName, setIdentityMetaData, setIdentityType, setInheritanceMetaData, setMetaDataComplete, setObjectIdClass, setPersistenceCapableSuperclass, setPersistenceModifier, setPrimaryKeyMetaData, setRequiresExtent, setRequiresExtent, setSchema, setSerializeRead, setTable, setVersionMetaData, usesSingleFieldIdentityClass, validateObjectIdClass, validateUnmappedColumns, validateUserInputForIdentity, validateUserInputForInheritanceMetaData
 
Methods inherited from class org.datanucleus.metadata.MetaData
addExtension, addExtension, assertIfInitialised, getExtensions, getNoOfExtensions, getParent, getValueForExtension, getValuesForExtension, hasExtension, isInitialised, isPopulated, isUsed, newExtensionMetaData, removeExtension, setParent, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

implementations

protected java.util.List<ImplementsMetaData> implementations
List of implements.


implementsMetaData

protected ImplementsMetaData[] implementsMetaData
ImplementsMetaData


isAbstract

protected boolean isAbstract
is the persistable class abstract.

Constructor Detail

ClassMetaData

public ClassMetaData(PackageMetaData parent,
                     java.lang.String name)
Constructor. Takes the basic string information found in the MetaData file.

Parameters:
parent - The package to which this class belongs
name - Name of class

ClassMetaData

public ClassMetaData(InterfaceMetaData imd,
                     java.lang.String implClassName,
                     boolean copyFields)
Constructor for creating the ClassMetaData for an implementation of a "persistent-interface".

Parameters:
imd - MetaData for the "persistent-interface"
implClassName - Name of the implementation class
copyFields - Whether to copy the fields of the interface too

ClassMetaData

public ClassMetaData(ClassMetaData cmd,
                     java.lang.String implClassName)
Constructor for creating the ClassMetaData for an implementation of a "persistent-abstract-class".

Parameters:
cmd - MetaData for the implementation of the "persistent-abstract-class"
implClassName - Name of the implementation class
Method Detail

populate

public void populate(ClassLoaderResolver clr,
                     java.lang.ClassLoader primary,
                     MetaDataManager mmgr)
Method to provide the details of the class being represented by this MetaData. This can be used to firstly provide defaults for attributes that aren't specified in the MetaData, and secondly to report any errors with attributes that have been specifed that are inconsistent with the class being represented.

One possible use of this method would be to take a basic ClassMetaData for a class and call this, passing in the users class. This would then add FieldMetaData for all fields in this class providing defaults for all of these.

Specified by:
populate in class AbstractClassMetaData
Parameters:
clr - ClassLoaderResolver to use in loading any classes
primary - the primary ClassLoader to use (or null)
mmgr - MetaData manager

addMetaDataForMembersNotInMetaData

protected void addMetaDataForMembersNotInMetaData(java.lang.Class cls,
                                                  MetaDataManager mmgr)
Add MetaData of fields/properties not declared in MetaData.

Parameters:
cls - Class represented by this metadata
mmgr - MetaData manager

populateMemberMetaData

protected void populateMemberMetaData(ClassLoaderResolver clr,
                                      java.lang.Class cls,
                                      boolean pkMembers,
                                      java.lang.ClassLoader primary,
                                      MetaDataManager mmgr)
Populate MetaData for all members.

Parameters:
clr - The ClassLoaderResolver
cls - This class
pkMembers - Process pk fields/properties (or non-PK if false)
primary - the primary ClassLoader to use (or null)
mmgr - MetaData manager
Throws:
InvalidMetaDataException - if the Class for a declared type in a field cannot be loaded by the clr
InvalidMetaDataException - if a field declared in the MetaData does not exist in the Class

initialise

public void initialise(ClassLoaderResolver clr,
                       MetaDataManager mmgr)
Method to initialise the object, creating internal convenience arrays. Initialises all sub-objects. populate() should be called BEFORE calling this.

Specified by:
initialise in class AbstractClassMetaData
Parameters:
clr - ClassLoader resolver
mmgr - MetaData manager

isAbstract

public boolean isAbstract()
Whether the PersistenceCapable class is abstract.

Returns:
true if the PersistenceCapable class is abstract

newDefaultedProperty

protected AbstractMemberMetaData newDefaultedProperty(java.lang.String name)
Utility to add a defaulted FieldMetaData to the class. Provided as a method since then any derived classes can override it (e.g ClassMetaData can create a FieldMetaData)

Overrides:
newDefaultedProperty in class AbstractClassMetaData
Parameters:
name - name of field
Returns:
the new FieldMetaData

getImplementsMetaData

public final ImplementsMetaData[] getImplementsMetaData()
Accessor for the implements MetaData

Returns:
Returns the implements MetaData.

implementsInterface

public boolean implementsInterface(java.lang.String interfaceName)
Convenience accessor for whether this class implements a specified interface

Parameters:
interfaceName - The name of the interface
Returns:
Whether it implements the interface

addImplements

public void addImplements(ImplementsMetaData implmd)
Method to add an implements to this class.

Parameters:
implmd - Meta-Data for the implements

toString

public java.lang.String toString(java.lang.String prefix,
                                 java.lang.String indent)
Returns a string representation of the object. This can be used as part of a facility to output a MetaData file.

Overrides:
toString in class MetaData
Parameters:
prefix - prefix string
indent - indent string
Returns:
a string representation of the object.


Copyright © 2010. All Rights Reserved.