org.apache.jdo.impl.model.jdo.caching
Class JDOClassImplCaching

java.lang.Object
  extended byorg.apache.jdo.impl.model.jdo.JDOElementImpl
      extended byorg.apache.jdo.impl.model.jdo.JDOMemberImpl
          extended byorg.apache.jdo.impl.model.jdo.JDOClassImplDynamic
              extended byorg.apache.jdo.impl.model.jdo.caching.JDOClassImplCaching
All Implemented Interfaces:
java.lang.Comparable, JDOClass, JDOElement, JDOMember

public class JDOClassImplCaching
extends JDOClassImplDynamic

An instance of this class represents the JDO metadata of a persistence capable class. This caching implementation caches any calulated value to avoid re-calculating it if it is requested again.

Since:
1.1
Version:
1.1
Author:
Michael Bouschen

Field Summary
 
Fields inherited from class org.apache.jdo.impl.model.jdo.JDOClassImplDynamic
identityType, javaType, msg, objectIdClass, pcSuperclass
 
Constructor Summary
JDOClassImplCaching()
           
 
Method Summary
protected  void calculateFieldNumbers()
          This method calculates the relative field number of the declared managed fields of this JDOClass and uddates the relativeFieldNumber property of the JDOField instance.
 JDOField createJDOField(java.lang.String name)
          This method returns a JDOField instance for the field with the specified name.
 JDOField[] getDeclaredManagedFields()
          Returns the collection of managed JDOField instances declared by this JDOClass in the form of an array.
 JDOField[] getDefaultFetchGroupFields()
          Returns the collection of default fetch group fields of this JDOClass in the form of an array.
 int getIdentityType()
          Get the JDO identity type of this JDOClass.
 int getInheritedManagedFieldCount()
          Returns the number of inherited managed fields for this class.
 JavaType getJavaType()
          Provides the JavaType representaion corresponding to 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.
 JDOClass getPersistenceCapableSuperclass()
          Returns the JDOClass instance for the persistence-capable superclass of 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.
protected  JDOClass newJDOClassInstance()
          Returns a new instance of the JDOClass implementation class.
protected  JDOField newJDOFieldInstance()
          Returns a new instance of the JDOField implementation class.
 void removeDeclaredMember(JDOMember member)
          Remove the supplied member from the collection of members maintained by this JDOClass.
 
Methods inherited from class org.apache.jdo.impl.model.jdo.JDOClassImplDynamic
createJDOClass, getDeclaredClasses, getDeclaredField, getDeclaredFields, getDeclaredManagedFieldCount, getDeclaredMembers, getDeclaredObjectIdClassName, getDeclaringModel, getField, getField, getFieldInternal, getJDOPackage, getManagedField, getManagedFieldCount, getPackagePrefix, getPersistenceCapableRootClass, getPersistenceCapableSuperclassName, isXMLMetadataLoaded, requiresExtent, setDeclaredObjectIdClassName, setDeclaringModel, setIdentityType, setJavaType, setJDOPackage, setObjectIdClass, setPersistenceCapableSuperclass, setPersistenceCapableSuperclassName, setRequiresExtent, setXMLMetadataLoaded
 
Methods inherited from class org.apache.jdo.impl.model.jdo.JDOMemberImpl
compareTo, equals, getDeclaringClass, getName, hashCode, setDeclaringClass, setName, toString
 
Methods inherited from class org.apache.jdo.impl.model.jdo.JDOElementImpl
addPropertyChangeListener, addVetoableChangeListener, createJDOExtension, firePropertyChange, fireVetoableChange, getJDOExtensions, removeJDOExtension, removePropertyChangeListener, removeVetoableChangeListener
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
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
 

Constructor Detail

JDOClassImplCaching

public JDOClassImplCaching()
Method Detail

getIdentityType

public 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.

Specified by:
getIdentityType in interface JDOClass
Overrides:
getIdentityType in class JDOClassImplDynamic
Returns:
the JDO identity type, one of JDOIdentityType.APPLICATION, JDOIdentityType.DATASTORE, or JDOIdentityType.NONDURABLE

getObjectIdClass

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

Specified by:
getObjectIdClass in interface JDOClass
Overrides:
getObjectIdClass in class JDOClassImplDynamic
Returns:
the JavaType representation of the object identity class.

getPersistenceCapableSuperclass

public 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.

Specified by:
getPersistenceCapableSuperclass in interface JDOClass
Overrides:
getPersistenceCapableSuperclass in class JDOClassImplDynamic
Returns:
the JDClass instance of the persistence-capable superclass or null if there is no persistence-capable superclass

getJavaType

public 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.

Specified by:
getJavaType in interface JDOClass
Overrides:
getJavaType in class JDOClassImplDynamic
Returns:
the JavaType object corresponding to this JDOClass.

removeDeclaredMember

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

Specified by:
removeDeclaredMember in interface JDOClass
Overrides:
removeDeclaredMember in class JDOClassImplDynamic
Parameters:
member - the member to be removed
Throws:
ModelException - if impossible

createJDOField

public 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.

Note, if the field numbers for the managed fields of this JDOClass are calculated, this methid will fail to create a new JDOField. Any new field would possibly invalidate existing field number

Specified by:
createJDOField in interface JDOClass
Overrides:
createJDOField in class JDOClassImplDynamic
Parameters:
name - the name of the field
Throws:
ModelException - if impossible

getDeclaredManagedFields

public 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:

Specified by:
getDeclaredManagedFields in interface JDOClass
Overrides:
getDeclaredManagedFields in class JDOClassImplDynamic
Returns:
the managed fields declared by this JDOClass

getManagedFields

public 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:

Specified by:
getManagedFields in interface JDOClass
Overrides:
getManagedFields in class JDOClassImplDynamic
Returns:
the managed fields of this JDOClass

getPersistentFields

public 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().

Specified by:
getPersistentFields in interface JDOClass
Overrides:
getPersistentFields in class JDOClassImplDynamic
Returns:
the persistent fields of this JDOClass

getPrimaryKeyFields

public 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()).

Specified by:
getPrimaryKeyFields in interface JDOClass
Overrides:
getPrimaryKeyFields in class JDOClassImplDynamic
Returns:
the identifying fields of this JDOClass

getPersistentRelationshipFields

public 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.

Specified by:
getPersistentRelationshipFields in interface JDOClass
Overrides:
getPersistentRelationshipFields in class JDOClassImplDynamic
Returns:
the persistent relationship fields of this JDOClass

getDefaultFetchGroupFields

public 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.

Specified by:
getDefaultFetchGroupFields in interface JDOClass
Overrides:
getDefaultFetchGroupFields in class JDOClassImplDynamic
Returns:
the default fetch group fields of this JDOClass
Since:
1.1

getManagedFieldNumbers

public 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

Specified by:
getManagedFieldNumbers in interface JDOClass
Overrides:
getManagedFieldNumbers in class JDOClassImplDynamic

getPersistentFieldNumbers

public 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.

Specified by:
getPersistentFieldNumbers in interface JDOClass
Overrides:
getPersistentFieldNumbers in class JDOClassImplDynamic

getPrimaryKeyFieldNumbers

public 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()).

Specified by:
getPrimaryKeyFieldNumbers in interface JDOClass
Overrides:
getPrimaryKeyFieldNumbers in class JDOClassImplDynamic
Returns:
array of numbers of the identifying fields

getPersistentNonPrimaryKeyFieldNumbers

public 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()).

Specified by:
getPersistentNonPrimaryKeyFieldNumbers in interface JDOClass
Overrides:
getPersistentNonPrimaryKeyFieldNumbers in class JDOClassImplDynamic
Returns:
array of numbers of the non identifying, persistent fields

getPersistentRelationshipFieldNumbers

public 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.

Specified by:
getPersistentRelationshipFieldNumbers in interface JDOClass
Overrides:
getPersistentRelationshipFieldNumbers in class JDOClassImplDynamic
Returns:
the field numbers of the persistent relationship fields

getPersistentSerializableFieldNumbers

public 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.

Specified by:
getPersistentSerializableFieldNumbers in interface JDOClass
Overrides:
getPersistentSerializableFieldNumbers in class JDOClassImplDynamic
Returns:
the field numbers of serializable fields

getInheritedManagedFieldCount

public int getInheritedManagedFieldCount()
Returns the number of inherited managed fields for this class.

Specified by:
getInheritedManagedFieldCount in interface JDOClass
Overrides:
getInheritedManagedFieldCount in class JDOClassImplDynamic
Returns:
number of inherited fields

calculateFieldNumbers

protected void calculateFieldNumbers()
This method calculates the relative field number of the declared managed fields of this JDOClass and uddates the relativeFieldNumber property of the JDOField instance.


newJDOClassInstance

protected JDOClass newJDOClassInstance()
Returns a new instance of the JDOClass implementation class.

Overrides:
newJDOClassInstance in class JDOClassImplDynamic

newJDOFieldInstance

protected JDOField newJDOFieldInstance()
Returns a new instance of the JDOField implementation class.

Overrides:
newJDOFieldInstance in class JDOClassImplDynamic


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