org.apache.jdo.model.jdo
Interface JDOClass

All Superinterfaces:
java.lang.Comparable, JDOElement, JDOMember
All Known Implementing Classes:
JDOClassImplCaching, JDOClassImplDynamic

public interface JDOClass
extends JDOMember

A JDOClass instance represents the JDO metadata of a persistence-capable class.

Version:
1.1
Author:
Michael Bouschen

Method Summary
 JDOClass createJDOClass(java.lang.String name)
          This method returns a JDOClass instance representing an inner class of this JDOClass If this JDOClass already declares such an inner class, the existing JDOClass instance is returned.
 JDOField createJDOField(java.lang.String name)
          This method returns a JDOField instance for the field with the specified name.
 JDOClass[] getDeclaredClasses()
          Returns the collection of JDOClass instances declared by this JDOClass.
 JDOField getDeclaredField(java.lang.String fieldName)
          Returns JDOField metadata for a particular declared field specified by field name.
 JDOField[] getDeclaredFields()
          Returns the collection of JDOField instances declared by this JDOClass in the form of an array.
 int getDeclaredManagedFieldCount()
          Returns the number of managed fields declared in the class represented by this JDOClass.
 JDOField[] getDeclaredManagedFields()
          Returns the collection of managed JDOField instances declared by this JDOClass in the form of an array.
 JDOMember[] getDeclaredMembers()
          Returns the collection of JDOMember instances declared by this JDOClass in form of an array.
 java.lang.String getDeclaredObjectIdClassName()
          Get the fully qualified name of the object identity class (primary key class) declared for this JDOClass.
 JDOModel getDeclaringModel()
          Returns the declaring JDOModel of this JDOClass.
 JDOField[] getDefaultFetchGroupFields()
          Returns the collection of default fetch group fields of this JDOClass in the form of an array.
 JDOField getField(int fieldNumber)
          Provides metadata for a particular field specified by the absolute field number.
 JDOField getField(java.lang.String fieldName)
          Returns JDOField metadata for a particular field specified by field name.
 int getIdentityType()
          Get the JDO identity type of this JDOClass.
 int getInheritedManagedFieldCount()
          Returns the number of inherited managed fields for the class represented by this JDOClass.
 JavaType getJavaType()
          Provides the JavaType representaion corresponding to this JDOClass.
 JDOPackage getJDOPackage()
          Returns the JDOPackage instance corresponding to the package name of this JDOClass.
 JDOField getManagedField(java.lang.String fieldName)
          Returns JDOField metadata for a particular managed field specified by field name.
 int getManagedFieldCount()
          Returns the number of managed fields for the class represented by this JDOClass.
 int[] getManagedFieldNumbers()
          Returns an array of absolute field numbers of the managed fields of this JDOClass.
 JDOField[] getManagedFields()
          Returns the collection of managed JDOField instances of this JDOClass in the form of an array.
 JavaType getObjectIdClass()
          Get the JavaType representation of the object identity class (primary key class) for this JDOClass.
 java.lang.String getPackagePrefix()
          Returns the package name including a terminating dot if this class has a package.
 JDOClass getPersistenceCapableRootClass()
          Returns the least-derived (topmost) persistence-capable class in the hierarchy of this JDOClass.
 JDOClass getPersistenceCapableSuperclass()
          Returns the JDOClass instance for the persistence-capable superclass of this JDOClass.
 java.lang.String getPersistenceCapableSuperclassName()
          Get the fully qualified class name of the persistence-capable superclass of the persistence-capable class described by this JDOClass.
 int[] getPersistentFieldNumbers()
          Returns an array of absolute field numbers of the persistent fields of this JDOClass.
 JDOField[] getPersistentFields()
          Returns the collection of persistent JDOField instances of this JDOClass in the form of an array.
 int[] getPersistentNonPrimaryKeyFieldNumbers()
          Returns an array of absolute field numbers of the non identifying, persistent fields of this JDOClass.
 int[] getPersistentRelationshipFieldNumbers()
          Returns an array of absolute field numbers of persistent relationship fields of this JDOClass.
 JDOField[] getPersistentRelationshipFields()
          Returns the collection of persistent relationship fields of this JDOClass in the form of an array.
 int[] getPersistentSerializableFieldNumbers()
          Returns an array of absolute field numbers of persistent, serializable fields of this JDOClass.
 int[] getPrimaryKeyFieldNumbers()
          Returns an array of absolute field numbers of the identifying fields of this JDOClass.
 JDOField[] getPrimaryKeyFields()
          Returns the collection of identifying fields of this JDOClass in the form of an array.
 boolean isXMLMetadataLoaded()
          Determines whether the XML metadata for the class represented by this JDOClass has been loaded.
 void removeDeclaredMember(JDOMember member)
          Remove the supplied member from the collection of members maintained by this JDOClass.
 boolean requiresExtent()
          Determines whether an extent must be managed for the persistence-capable class described by this JDOClass.
 void setDeclaredObjectIdClassName(java.lang.String declaredObjectIdClassName)
          Set the fully qualified name of the object identity class (primary key class) declared for this JDOClass.
 void setDeclaringModel(JDOModel model)
          Set the declaring JDOModel for this JDOClass.
 void setIdentityType(int identityType)
          Set the object identity type of this JDOClass.
 void setJavaType(JavaType javaType)
          Set the JavaType representation corresponding to this JDOClass.
 void setJDOPackage(JDOPackage jdoPackage)
          Sets the JDOPackage instance corresponding to the package name of this JDOClass.
 void setObjectIdClass(JavaType objectIdClass)
          Set the JavaType representation of the object identity class (primary key class) for this JDOClass.
 void setPersistenceCapableSuperclass(JDOClass pcSuperclass)
          Set the JDOClass for the persistence-capable superclass of this JDOClass.
 void setPersistenceCapableSuperclassName(java.lang.String pcSuperclassName)
          Set the fully qualified class name of the persistence-capable superclass of the persistence-capable class described by this JDOClass.
 void setRequiresExtent(boolean requiresExtent)
          Set whether an extent must be managed for the persistence-capable class described by this JDOClass.
 void setXMLMetadataLoaded()
          Sets the flag indicating that the class XML metadata for this JDOClass is loaded to true.
 
Methods inherited from interface org.apache.jdo.model.jdo.JDOMember
getDeclaringClass, getName, setDeclaringClass, setName
 
Methods inherited from interface org.apache.jdo.model.jdo.JDOElement
addPropertyChangeListener, addVetoableChangeListener, createJDOExtension, getJDOExtensions, removeJDOExtension, removePropertyChangeListener, removeVetoableChangeListener
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Method Detail

getIdentityType

int getIdentityType()
Get the JDO identity type of this JDOClass. The identity type of the least-derived persistence-capable class defines the identity type for all persistence-capable classes that extend it. The identity type of the least-derived persistence-capable class is defaulted to JDOIdentityType.APPLICATION if objectid-class is specified, and JDOIdentityType.DATASTORE, if not.

Returns:
the JDO identity type, one of JDOIdentityType.APPLICATION, JDOIdentityType.DATASTORE, or JDOIdentityType.NONDURABLE

setIdentityType

void setIdentityType(int identityType)
                     throws ModelException
Set the object identity type of this JDOClass.

Parameters:
identityType - an integer indicating the JDO identity type, one of: JDOIdentityType.APPLICATION, JDOIdentityType.DATASTORE, or JDOIdentityType.NONDURABLE
Throws:
ModelException - if impossible

getObjectIdClass

JavaType getObjectIdClass()
Get the JavaType representation of the object identity class (primary key class) for this JDOClass.

Returns:
the JavaType representation of the object identity class.

setObjectIdClass

void setObjectIdClass(JavaType objectIdClass)
                      throws ModelException
Set the JavaType representation of the object identity class (primary key class) for this JDOClass.

Parameters:
objectIdClass - the JavaType representation of the object identity class.
Throws:
ModelException - if impossible

getDeclaredObjectIdClassName

java.lang.String getDeclaredObjectIdClassName()
Get the fully qualified name of the object identity class (primary key class) declared for this JDOClass. Please note, this method returns a non null class name, only if the JDO metadata defines an objectIdClass for exactly the pc class represented by this JDOClass. If there is no objectIdClass defines for this JDOClass, but any of the pc-superclasses defines an objectIdClass, this method returns null. This is different from method getObjectIdClass() which returns a non-null value, if the superclass defines a objectIdClass.

Returns:
the name of the object identity class.

setDeclaredObjectIdClassName

void setDeclaredObjectIdClassName(java.lang.String declaredObjectIdClassName)
                                  throws ModelException
Set the fully qualified name of the object identity class (primary key class) declared for this JDOClass.

Parameters:
declaredObjectIdClassName - the name of the object identity class
Throws:
ModelException - if impossible

requiresExtent

boolean requiresExtent()
Determines whether an extent must be managed for the persistence-capable class described by this JDOClass.

Returns:
true if this class must manage an extent; false otherwise

setRequiresExtent

void setRequiresExtent(boolean requiresExtent)
                       throws ModelException
Set whether an extent must be managed for the persistence-capable class described by this JDOClass.

Parameters:
requiresExtent - true if this class must manage an extent; false otherwise
Throws:
ModelException - if impossible

getPersistenceCapableSuperclassName

java.lang.String getPersistenceCapableSuperclassName()
Get the fully qualified class name of the persistence-capable superclass of the persistence-capable class described by this JDOClass. If this class does not have a persistence-capable superclass then null is returned.

Returns:
the fully qualified name of the persistence-capable superclass or null if there is no persistence-capable superclass

setPersistenceCapableSuperclassName

void setPersistenceCapableSuperclassName(java.lang.String pcSuperclassName)
                                         throws ModelException
Set the fully qualified class name of the persistence-capable superclass of the persistence-capable class described by this JDOClass.

Parameters:
pcSuperclassName - the fully qualified name of the persistence-capable superclass
Throws:
ModelException - if impossible

getJavaType

JavaType getJavaType()
Provides the JavaType representaion corresponding to this JDOClass.

Note the difference between Object.getClass) and this method. The former returns the class of the object in hand, this returns the class of the object represented by this meta data.

Returns:
the JavaType object corresponding to this JDOClass.

setJavaType

void setJavaType(JavaType javaType)
                 throws ModelException
Set the JavaType representation corresponding to this JDOClass.

Parameters:
javaType - the JavaType representation for this JDOClass.
Throws:
ModelException - if impossible

isXMLMetadataLoaded

boolean isXMLMetadataLoaded()
Determines whether the XML metadata for the class represented by this JDOClass has been loaded.

Returns:
true if XML metadata is loaded; false otherwise

setXMLMetadataLoaded

void setXMLMetadataLoaded()
Sets the flag indicating that the class XML metadata for this JDOClass is loaded to true.


removeDeclaredMember

void removeDeclaredMember(JDOMember member)
                          throws ModelException
Remove the supplied member from the collection of members maintained by this JDOClass.

Parameters:
member - the member to be removed
Throws:
ModelException - if impossible

getDeclaredMembers

JDOMember[] getDeclaredMembers()
Returns the collection of JDOMember instances declared by this JDOClass in form of an array.

Returns:
the members declared by this JDOClass

getDeclaringModel

JDOModel getDeclaringModel()
Returns the declaring JDOModel of this JDOClass.

Returns:
the JDOModel that owns this JDOClass

setDeclaringModel

void setDeclaringModel(JDOModel model)
Set the declaring JDOModel for this JDOClass.

Parameters:
model - the declaring JDOModel of this JDOClass

getPersistenceCapableSuperclass

JDOClass getPersistenceCapableSuperclass()
Returns the JDOClass instance for the persistence-capable superclass of this JDOClass. If this class does not have a persistence-capable superclass then null is returned.

Returns:
the JDClass instance of the persistence-capable superclass or null if there is no persistence-capable superclass

setPersistenceCapableSuperclass

void setPersistenceCapableSuperclass(JDOClass pcSuperclass)
                                     throws ModelException
Set the JDOClass for the persistence-capable superclass of this JDOClass.

Parameters:
pcSuperclass - the JDClass instance of the persistence-capable superclass
Throws:
ModelException - if impossible

getJDOPackage

JDOPackage getJDOPackage()
Returns the JDOPackage instance corresponding to the package name of this JDOClass.

Returns:
the JDOPackage instance of this JDOClass.

setJDOPackage

void setJDOPackage(JDOPackage jdoPackage)
Sets the JDOPackage instance corresponding to the package name of this JDOClass.

Parameters:
jdoPackage - the JDOPackage of this JDOClass.

createJDOField

JDOField createJDOField(java.lang.String name)
                        throws ModelException
This method returns a JDOField instance for the field with the specified name. If this JDOClass already declares such a field, the existing JDOField instance is returned. Otherwise, it creates a new JDOField instance, sets its declaringClass and returns the new instance.

Parameters:
name - the name of the field
Throws:
ModelException - if impossible

createJDOClass

JDOClass createJDOClass(java.lang.String name)
                        throws ModelException
This method returns a JDOClass instance representing an inner class of this JDOClass If this JDOClass already declares such an inner class, the existing JDOClass instance is returned. Otherwise, it creates a new JDOClass instance, sets its declaringClass and returns the new instance.

Parameters:
name - the name of the inner class
Throws:
ModelException - if impossible

getDeclaredClasses

JDOClass[] getDeclaredClasses()
Returns the collection of JDOClass instances declared by this JDOClass.

Returns:
the classes declared by this JDOClass

getDeclaredFields

JDOField[] getDeclaredFields()
Returns the collection of JDOField instances declared by this JDOClass in the form of an array. This does not include inherited fields.

Returns:
the fields declared by this JDOClass

getDeclaredManagedFields

JDOField[] getDeclaredManagedFields()
Returns the collection of managed JDOField instances declared by this JDOClass in the form of an array. The returned array does not include inherited fields. A field is a managed field, if it has the persistence-modifier PersistenceModifier.PERSISTENT or PersistenceModifier.TRANSACTIONAL. The position of the fields in the returned array equals their relative field number as returned by JDOField.getRelativeFieldNumber(). The following holds true for any field in the returned array:
  • getDeclaredManagedFields()[i].getRelativeFieldNumber() == i
  • getDeclaredManagedFields()[field.getRelativeFieldNumber()] == field

Returns:
the managed fields declared by this JDOClass

getManagedFields

JDOField[] getManagedFields()
Returns the collection of managed JDOField instances of this JDOClass in the form of an array. The returned array includes inherited fields. A field is a managed field, if it has the persistence-modifier PersistenceModifier.PERSISTENT or PersistenceModifier.TRANSACTIONAL. The position of the fields in the returned array equals their absolute field number as returned by JDOField.getFieldNumber(). The following holds true for any field in the returned array:
  • getManagedFields()[i].getFieldNumber() == i
  • getManagedFields()[field.getFieldNumber()] == field

Returns:
the managed fields of this JDOClass

getPersistentFields

JDOField[] getPersistentFields()
Returns the collection of persistent JDOField instances of this JDOClass in the form of an array. The returned array includes inherited fields. A field is a persistent field, if it has the persistence-modifier PersistenceModifier.PERSISTENT. Please note, the position of the fields in the returned array might not equal their absolute field number as returned by JDOField.getFieldNumber().

Returns:
the persistent fields of this JDOClass

getPrimaryKeyFields

JDOField[] getPrimaryKeyFields()
Returns the collection of identifying fields of this JDOClass in the form of an array. The method returns the JDOField instances defined as primary key fields (see JDOField.isPrimaryKey()).

Returns:
the identifying fields of this JDOClass

getPersistentRelationshipFields

JDOField[] getPersistentRelationshipFields()
Returns the collection of persistent relationship fields of this JDOClass in the form of an array. The method returns the JDOField instances defined as relationship (method JDOField.getRelationship() returns a non null value) and having the persistence-modifier PersistenceModifier.PERSISTENT.

Returns:
the persistent relationship fields of this JDOClass

getDefaultFetchGroupFields

JDOField[] getDefaultFetchGroupFields()
Returns the collection of default fetch group fields of this JDOClass in the form of an array. The method returns the JDOField instances defined as part of the default fetch group (method JDOField.isDefaultFetchGroup() returns true.

Returns:
the default fetch group fields of this JDOClass
Since:
1.1

getManagedFieldNumbers

int[] getManagedFieldNumbers()
Returns an array of absolute field numbers of the managed fields of this JDOClass. The returned array includes field numbers of inherited fields. A field is a managed field, if it has the persistence-modifier PersistenceModifier.PERSISTENT or PersistenceModifier.TRANSACTIONAL. Only managed fields have a valid field number, thus the field number in the returned array equals its index:
getManagedFields()[i] == i


getPersistentFieldNumbers

int[] getPersistentFieldNumbers()
Returns an array of absolute field numbers of the persistent fields of this JDOClass. The returned array includes field numbers of inherited fields. A persistent field has the persistence-modifier PersistenceModifier.PERSISTENT.


getPrimaryKeyFieldNumbers

int[] getPrimaryKeyFieldNumbers()
Returns an array of absolute field numbers of the identifying fields of this JDOClass. A field number is included in the returned array, iff the corresponding JDOField instance is defined as primary key field (see JDOField.isPrimaryKey()).

Returns:
array of numbers of the identifying fields

getPersistentNonPrimaryKeyFieldNumbers

int[] getPersistentNonPrimaryKeyFieldNumbers()
Returns an array of absolute field numbers of the non identifying, persistent fields of this JDOClass. A field number is included in the returned array, iff the corresponding JDOField instance is persistent and not a not a primary key field (see JDOField.isPrimaryKey()). A field is a persistent field, if it has the persistence-modifier PersistenceModifier.PERSISTENT or (see JDOField.getPersistenceModifier()).

Returns:
array of numbers of the non identifying, persistent fields

getPersistentRelationshipFieldNumbers

int[] getPersistentRelationshipFieldNumbers()
Returns an array of absolute field numbers of persistent relationship fields of this JDOClass. A field number is included in the returned array, iff the corresponding JDOField instance is a relationship (method JDOField.getRelationship() returns a non null value) and has the persistence-modifier PersistenceModifier.PERSISTENT.

Returns:
the field numbers of the persistent relationship fields

getPersistentSerializableFieldNumbers

int[] getPersistentSerializableFieldNumbers()
Returns an array of absolute field numbers of persistent, serializable fields of this JDOClass. A field number is included in the returned array, iff the corresponding JDOField instance is serializable (method JDOField.isSerializable() returns true) and has the persistence-modifier PersistenceModifier.PERSISTENT.

Returns:
the field numbers of serializable fields

getManagedField

JDOField getManagedField(java.lang.String fieldName)
Returns JDOField metadata for a particular managed field specified by field name. It returns null if the specified name does not denote a managed field of this JDOClass. The field name may be unqualified and or qualified (see getField(String fieldName)).

Parameters:
fieldName - the name of the managed field for which field metadata is needed.
Returns:
JDOField metadata for the managed field or null if there is no such field.

getField

JDOField getField(java.lang.String fieldName)
Returns JDOField metadata for a particular field specified by field name. It returns null if the specified name does not denote a field of this JDOClass.

The method supports lookup by unqualified and by qualified field name.

  • In the case of an unqualified field name the method starts checking this JDOClass for a field with the specified name. If this class does not define such a field, it checks the inheritance hierarchy starting with its direct persistence-capable superclass. The method finds the first field with the specified name in a bootom-up lookup of the inheritance hierarchy. Hidden fields are not visible.
  • In the case of a qualified field name the method assumes a fully qualified class name (called qualifier class) as the field qualifier. The qualifier class must be a either this class or a persistence-capable superclass (direct or indirect) of this class. Then the method searches the field definition in the inheritance hierarchy staring with the qualifier class. Any field declarations with the same name in subclasses of the qualifier class are not considered. This form allows accessing fields hidden by subclasses. The method returns null if the qualifier class does not denote a valid class or if the qualifier class is not a persistence-capable superclass of this class.

Parameters:
fieldName - the unqualified or qualified name of field for which field metadata is needed.
Returns:
JDOField metadata for the field or null if there is no such field.

getField

JDOField getField(int fieldNumber)
Provides metadata for a particular field specified by the absolute field number. The field number must be a valid absolute field number for this JDOClass: 0 <= fieldNumber < this.getManagedFields().length If the field number is valid the returned JDoField instance denotes a managed field, meaning the field has the persistence-modifier PersistenceModifier.PERSISTENT or PersistenceModifier.TRANSACTIONAL. If the field number is not valid then the method returns null.

Parameters:
fieldNumber - the number for which field metadata is needed.
Returns:
JDOField metadata for the field or null if there is no such field.

getDeclaredField

JDOField getDeclaredField(java.lang.String fieldName)
Returns JDOField metadata for a particular declared field specified by field name. Please note, the method does not return inherited fields. The field name must not be qualified by a class name. The method returns null if the field name does not denote a field declared by JDOClass.

Parameters:
fieldName - the unqualified name of field for which field metadata is needed.
Returns:
JDOField metadata for the field or null if there is no such field declared by this JDOClass.

getDeclaredManagedFieldCount

int getDeclaredManagedFieldCount()
Returns the number of managed fields declared in the class represented by this JDOClass. This does not include inherited fields.

Returns:
number of declared managed fields

getInheritedManagedFieldCount

int getInheritedManagedFieldCount()
Returns the number of inherited managed fields for the class represented by this JDOClass.

Returns:
number of inherited managed fields

getManagedFieldCount

int getManagedFieldCount()
Returns the number of managed fields for the class represented by this JDOClass. The value returned by this method is equal to getDeclaredManagedFieldCount() + getInheritedManagedFieldCount().

Returns:
number of managed fields

getPackagePrefix

java.lang.String getPackagePrefix()
Returns the package name including a terminating dot if this class has a package. The method returns the empty string if this class is in the default package.

Returns:
package prefix for this class.

getPersistenceCapableRootClass

JDOClass getPersistenceCapableRootClass()
Returns the least-derived (topmost) persistence-capable class in the hierarchy of this JDOClass. It returns this JDOClass if it has no persistence-capable superclass.

Returns:
the topmost persistence-capable class in the hierarchy.


Copyright © 2005-2012 Apache Software Foundation. All Rights Reserved.