org.apache.jdo.impl.enhancer.meta.model
Class EnhancerMetaDataJDOModelImpl

java.lang.Object
  extended byorg.apache.jdo.impl.enhancer.util.Assertion
      extended byorg.apache.jdo.impl.enhancer.util.Support
          extended byorg.apache.jdo.impl.enhancer.meta.util.EnhancerMetaDataBaseModel
              extended byorg.apache.jdo.impl.enhancer.meta.model.EnhancerMetaDataJDOModelImpl
All Implemented Interfaces:
EnhancerMetaData

public class EnhancerMetaDataJDOModelImpl
extends EnhancerMetaDataBaseModel
implements EnhancerMetaData

Provides the JDO meta information based on a JDO meta model.


Field Summary
private  EnhancerJavaModel javaModel
          The model instance.
private  org.apache.jdo.model.jdo.JDOModel jdoModel
          The jdoModel instance.
private  org.apache.jdo.model.java.JavaType serializableJavaType
          The JavaType representation for java.io.Serializable.
 
Fields inherited from class org.apache.jdo.impl.enhancer.meta.util.EnhancerMetaDataBaseModel
out, unenhancableTypePrefixes, verbose
 
Fields inherited from class org.apache.jdo.impl.enhancer.util.Support
timer
 
Fields inherited from interface org.apache.jdo.impl.enhancer.meta.EnhancerMetaData
CHECK_READ, CHECK_WRITE, MEDIATE_READ, MEDIATE_WRITE, SERIALIZABLE
 
Constructor Summary
EnhancerMetaDataJDOModelImpl(java.io.PrintWriter out, boolean verbose, java.util.List jdoFileNames, java.util.List jarFileNames, java.lang.String sourcePath)
          Creates an instance.
 
Method Summary
 void declareField(java.lang.String classPath, java.lang.String fieldName, java.lang.String fieldSig)
          Declares a field to the JDO model passing its type information.
 java.lang.String getDeclaringClass(java.lang.String classPath, java.lang.String fieldName)
          Returns the JVM-qualified name of the specified field's declaring class.
 int getFieldNumber(java.lang.String classPath, java.lang.String fieldName)
          Returns the unique field index of a declared, persistent field of a class.
private  org.apache.jdo.model.jdo.JDOClass getJDOClass(java.lang.String classPath)
           
private  org.apache.jdo.model.jdo.JDOField getJDOField(java.lang.String classPath, java.lang.String fieldName)
           
 java.lang.String getKeyClass(java.lang.String classPath)
          Returns the name of the key class of a persistence-capable class.
 java.lang.String[] getManagedFields(java.lang.String classPath)
          Returns an array of field names of all declared persistent and transactional fields of a class.
 java.lang.String getPersistenceCapableSuperClass(java.lang.String classPath)
          Returns the name of the persistence-capable superclass of a class.
private  boolean hasFieldModifier(java.lang.String classPath, java.lang.String fieldName, int fieldModifier)
           
 boolean isDefaultFetchGroupField(java.lang.String classPath, java.lang.String fieldName)
          Tests whether a field of a class is known to be part of the Default Fetch Group.
 boolean isKeyField(java.lang.String classPath, java.lang.String fieldName)
          Tests whether a field of a class is known to be Key.
 boolean isKnownNonManagedField(java.lang.String classPath, java.lang.String fieldName, java.lang.String fieldSig)
          Returns whether a field of a class is known to be non-managed.
 boolean isManagedField(java.lang.String classPath, java.lang.String fieldName)
          Tests whether a field of a class is transient transactional or persistent.
 boolean isPersistenceCapableClass(java.lang.String classPath)
          Tests whether a class is known to be persistence-capable.
 boolean isPersistentField(java.lang.String classPath, java.lang.String fieldName)
          Tests whether a field of a class is persistent.
 boolean isSerializableClass(java.lang.String classPath)
          Returns whether a class implements java.io.Serializable
 boolean isTransactionalField(java.lang.String classPath, java.lang.String fieldName)
          Tests whether a field of a class is transient transactional.
 
Methods inherited from class org.apache.jdo.impl.enhancer.meta.util.EnhancerMetaDataBaseModel
getFieldFlags, getFieldFlags, getFieldNumber, getKeyFields, getPersistenceCapableRootClass, getSuperKeyClass, isKnownUnenhancableClass, isPersistenceCapableRootClass, printMessage, printWarning
 
Methods inherited from class org.apache.jdo.impl.enhancer.util.Support
getI18N, getI18N, getI18N, getI18N, getI18N, getI18N
 
Methods inherited from class org.apache.jdo.impl.enhancer.util.Assertion
affirm, affirm, affirm, affirm
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.jdo.impl.enhancer.meta.EnhancerMetaData
getFieldFlags, getFieldFlags, getFieldNumber, getKeyFields, getPersistenceCapableRootClass, getSuperKeyClass, isKnownUnenhancableClass, isPersistenceCapableRootClass
 

Field Detail

jdoModel

private final org.apache.jdo.model.jdo.JDOModel jdoModel
The jdoModel instance.


javaModel

private final EnhancerJavaModel javaModel
The model instance.


serializableJavaType

private final org.apache.jdo.model.java.JavaType serializableJavaType
The JavaType representation for java.io.Serializable.

Constructor Detail

EnhancerMetaDataJDOModelImpl

public EnhancerMetaDataJDOModelImpl(java.io.PrintWriter out,
                                    boolean verbose,
                                    java.util.List jdoFileNames,
                                    java.util.List jarFileNames,
                                    java.lang.String sourcePath)
                             throws EnhancerMetaDataFatalError
Creates an instance.

Method Detail

getJDOClass

private org.apache.jdo.model.jdo.JDOClass getJDOClass(java.lang.String classPath)
                                               throws EnhancerMetaDataUserException,
                                                      EnhancerMetaDataFatalError
Throws:
EnhancerMetaDataUserException
EnhancerMetaDataFatalError

getJDOField

private org.apache.jdo.model.jdo.JDOField getJDOField(java.lang.String classPath,
                                                      java.lang.String fieldName)
                                               throws EnhancerMetaDataUserException,
                                                      EnhancerMetaDataFatalError
Throws:
EnhancerMetaDataUserException
EnhancerMetaDataFatalError

hasFieldModifier

private boolean hasFieldModifier(java.lang.String classPath,
                                 java.lang.String fieldName,
                                 int fieldModifier)
                          throws EnhancerMetaDataUserException,
                                 EnhancerMetaDataFatalError
Throws:
EnhancerMetaDataUserException
EnhancerMetaDataFatalError

getDeclaringClass

public java.lang.String getDeclaringClass(java.lang.String classPath,
                                          java.lang.String fieldName)
                                   throws EnhancerMetaDataUserException,
                                          EnhancerMetaDataFatalError
Returns the JVM-qualified name of the specified field's declaring class. The method first checks whether the class of the specified classPath (the JVM-qualified name) declares such a field. If yes, classPath is returned. Otherwise, it checks its superclasses. The method returns null for an unkown field.

Specified by:
getDeclaringClass in interface EnhancerMetaData
Parameters:
classPath - the non-null JVM-qualified name of the class
fieldName - the non-null name of the field
Returns:
the JVM-qualified name of the declararing class of the field, or null if there is no such field.
Throws:
EnhancerMetaDataUserException
EnhancerMetaDataFatalError

declareField

public void declareField(java.lang.String classPath,
                         java.lang.String fieldName,
                         java.lang.String fieldSig)
                  throws EnhancerMetaDataUserException,
                         EnhancerMetaDataFatalError
Declares a field to the JDO model passing its type information.

Specified by:
declareField in interface EnhancerMetaData
Parameters:
classPath - the non-null JVM-qualified name of the class
fieldName - the non-null name of the field
fieldSig - the non-null JVM signature of the field
Throws:
EnhancerMetaDataUserException
EnhancerMetaDataFatalError
See Also:
EnhancerMetaData.isPersistenceCapableClass(String)

isPersistenceCapableClass

public boolean isPersistenceCapableClass(java.lang.String classPath)
                                  throws EnhancerMetaDataUserException,
                                         EnhancerMetaDataFatalError
Tests whether a class is known to be persistence-capable.

Specified by:
isPersistenceCapableClass in interface EnhancerMetaData
Parameters:
classPath - the non-null JVM-qualified name of the class
Returns:
true if this class is persistence-capable; otherwise false
Throws:
EnhancerMetaDataUserException
EnhancerMetaDataFatalError
See Also:
EnhancerMetaData.isKnownUnenhancableClass(String)

isSerializableClass

public boolean isSerializableClass(java.lang.String classPath)
                            throws EnhancerMetaDataUserException,
                                   EnhancerMetaDataFatalError
Returns whether a class implements java.io.Serializable

Specified by:
isSerializableClass in interface EnhancerMetaData
Parameters:
classPath - the non-null JVM-qualified name of the class
Returns:
true if this class is serializable; otherwise false
Throws:
EnhancerMetaDataUserException
EnhancerMetaDataFatalError

getPersistenceCapableSuperClass

public java.lang.String getPersistenceCapableSuperClass(java.lang.String classPath)
                                                 throws EnhancerMetaDataUserException,
                                                        EnhancerMetaDataFatalError
Returns the name of the persistence-capable superclass of a class.

Specified by:
getPersistenceCapableSuperClass in interface EnhancerMetaData
Parameters:
classPath - the non-null JVM-qualified name of the class
Returns:
the name of the PC superclass or null if there is none
Throws:
EnhancerMetaDataUserException
EnhancerMetaDataFatalError
See Also:
EnhancerMetaData.isPersistenceCapableClass(String), EnhancerMetaData.getPersistenceCapableRootClass(String)

getKeyClass

public java.lang.String getKeyClass(java.lang.String classPath)
                             throws EnhancerMetaDataUserException,
                                    EnhancerMetaDataFatalError
Returns the name of the key class of a persistence-capable class.

Specified by:
getKeyClass in interface EnhancerMetaData
Parameters:
classPath - the non-null JVM-qualified name of the class
Returns:
the name of the key class or null if there is none
Throws:
EnhancerMetaDataUserException
EnhancerMetaDataFatalError
See Also:
EnhancerMetaData.isPersistenceCapableClass(String)

getManagedFields

public java.lang.String[] getManagedFields(java.lang.String classPath)
                                    throws EnhancerMetaDataUserException,
                                           EnhancerMetaDataFatalError
Returns an array of field names of all declared persistent and transactional fields of a class.

Specified by:
getManagedFields in interface EnhancerMetaData
Parameters:
classPath - the non-null JVM-qualified name of the class
Returns:
an array of all declared persistent and transactional fields of a class
Throws:
EnhancerMetaDataUserException
EnhancerMetaDataFatalError
See Also:
EnhancerMetaData.getFieldNumber(String, String), EnhancerMetaData.declareField(String, String, String)

isKnownNonManagedField

public boolean isKnownNonManagedField(java.lang.String classPath,
                                      java.lang.String fieldName,
                                      java.lang.String fieldSig)
                               throws EnhancerMetaDataUserException,
                                      EnhancerMetaDataFatalError
Returns whether a field of a class is known to be non-managed.

Specified by:
isKnownNonManagedField in interface EnhancerMetaData
Parameters:
classPath - the non-null JVM-qualified name of the class
fieldName - the non-null name of the field
fieldSig - the non-null type signature of the field
Returns:
true if this field is known to be non-managed; otherwise false
Throws:
EnhancerMetaDataUserException
EnhancerMetaDataFatalError
See Also:
EnhancerMetaData.isManagedField(String, String), EnhancerMetaData.declareField(String, String, String)

isManagedField

public boolean isManagedField(java.lang.String classPath,
                              java.lang.String fieldName)
                       throws EnhancerMetaDataUserException,
                              EnhancerMetaDataFatalError
Tests whether a field of a class is transient transactional or persistent.

Specified by:
isManagedField in interface EnhancerMetaData
Overrides:
isManagedField in class EnhancerMetaDataBaseModel
Throws:
EnhancerMetaDataUserException
EnhancerMetaDataFatalError
See Also:
EnhancerMetaData.isManagedField(String, String)

isPersistentField

public boolean isPersistentField(java.lang.String classPath,
                                 java.lang.String fieldName)
                          throws EnhancerMetaDataUserException,
                                 EnhancerMetaDataFatalError
Tests whether a field of a class is persistent.

Specified by:
isPersistentField in interface EnhancerMetaData
Parameters:
classPath - the non-null JVM-qualified name of the class
fieldName - the non-null name of the field
Returns:
true if this field is persistent; otherwise false
Throws:
EnhancerMetaDataUserException
EnhancerMetaDataFatalError
See Also:
EnhancerMetaData.isManagedField(String, String), EnhancerMetaData.declareField(String, String, String)

isTransactionalField

public boolean isTransactionalField(java.lang.String classPath,
                                    java.lang.String fieldName)
                             throws EnhancerMetaDataUserException,
                                    EnhancerMetaDataFatalError
Tests whether a field of a class is transient transactional.

Specified by:
isTransactionalField in interface EnhancerMetaData
Parameters:
classPath - the non-null JVM-qualified name of the class
fieldName - the non-null name of the field
Returns:
true if this field is transactional; otherwise false
Throws:
EnhancerMetaDataUserException
EnhancerMetaDataFatalError
See Also:
EnhancerMetaData.isManagedField(String, String), EnhancerMetaData.declareField(String, String, String)

isKeyField

public boolean isKeyField(java.lang.String classPath,
                          java.lang.String fieldName)
                   throws EnhancerMetaDataUserException,
                          EnhancerMetaDataFatalError
Tests whether a field of a class is known to be Key.

Specified by:
isKeyField in interface EnhancerMetaData
Parameters:
classPath - the non-null JVM-qualified name of the class
fieldName - the non-null name of the field
Returns:
true if this field is key; otherwise false
Throws:
EnhancerMetaDataUserException
EnhancerMetaDataFatalError
See Also:
EnhancerMetaData.isPersistentField(String, String), EnhancerMetaData.declareField(String, String, String)

isDefaultFetchGroupField

public boolean isDefaultFetchGroupField(java.lang.String classPath,
                                        java.lang.String fieldName)
                                 throws EnhancerMetaDataUserException,
                                        EnhancerMetaDataFatalError
Tests whether a field of a class is known to be part of the Default Fetch Group.

Specified by:
isDefaultFetchGroupField in interface EnhancerMetaData
Parameters:
classPath - the non-null JVM-qualified name of the class
fieldName - the non-null name of the field
Returns:
true if this field is part of the default fetch group; otherwise false
Throws:
EnhancerMetaDataUserException
EnhancerMetaDataFatalError
See Also:
EnhancerMetaData.isPersistentField(String, String), EnhancerMetaData.declareField(String, String, String)

getFieldNumber

public int getFieldNumber(java.lang.String classPath,
                          java.lang.String fieldName)
                   throws EnhancerMetaDataUserException,
                          EnhancerMetaDataFatalError
Returns the unique field index of a declared, persistent field of a class.

Specified by:
getFieldNumber in interface EnhancerMetaData
Parameters:
classPath - the non-null JVM-qualified name of the class
fieldName - the non-null name of the field
Returns:
the non-negative, unique field index or -1 if the field is non-managed
Throws:
EnhancerMetaDataUserException
EnhancerMetaDataFatalError
See Also:
EnhancerMetaData.getManagedFields(String), EnhancerMetaData.declareField(String, String, String)