org.apache.jdo.impl.model.java.reflection
Class ReflectionJavaType

java.lang.Object
  extended by org.apache.jdo.impl.model.java.AbstractJavaType
      extended by org.apache.jdo.impl.model.java.BaseReflectionJavaType
          extended by org.apache.jdo.impl.model.java.reflection.ReflectionJavaType
All Implemented Interfaces:
JavaType
Direct Known Subclasses:
EnhancerJavaType, RuntimeJavaType

public abstract class ReflectionJavaType
extends BaseReflectionJavaType

/** A reflection based JavaType implementation used at runtime. The implementation takes java.lang.Class and java.lang.reflect.Field instances to get Java related metadata about types and fields.

Since:
JDO 1.1
Author:
Michael Bouschen

Field Summary
 
Fields inherited from class org.apache.jdo.impl.model.java.BaseReflectionJavaType
clazz, superclass
 
Constructor Summary
ReflectionJavaType(java.lang.Class clazz, JDOModel jdoModel)
          Constructor.
 
Method Summary
 JavaField createJavaField(JDOField jdoField, JavaType type)
          RegisterClassListener calls this method to create a ReflectionJavaField instance when processing the enhancer generated metadata.
 JavaType getArrayComponentType()
          Returns the JavaType representing the component type of an array.
 JavaField getDeclaredJavaField(java.lang.String fieldName)
          Returns a JavaField instance that reflects the declared field with the specified name of the class or interface represented by this JavaType instance.
 JavaField getJavaField(java.lang.String fieldName)
          Returns a JavaField instance that reflects the field with the specified name of the class or interface represented by this JavaType instance.
protected abstract  JavaType getJavaTypeInternal(java.lang.Class clazz)
          Returns a JavaType instance for the specified Class object.
 JDOClass getJDOClass()
          Returns the JDOClass instance if this JavaType represents a persistence capable class.
 JavaType getSuperclass()
          Returns the JavaType representing the superclass of the entity represented by this JavaType.
 boolean isArray()
          Determines if this JavaType object represents an array type.
 boolean isPersistenceCapable()
          Returns true if this JavaType represents a persistence capable class.
 
Methods inherited from class org.apache.jdo.impl.model.java.BaseReflectionJavaType
getJavaClass, getModifiers, getName, isCompatibleWith, isInterface
 
Methods inherited from class org.apache.jdo.impl.model.java.AbstractJavaType
equals, hashCode, isFloatingPoint, isIntegral, isJDOSupportedCollection, isJDOSupportedMap, isOrderable, isPrimitive, isTrackable, isValue, isWrapperClass, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ReflectionJavaType

public ReflectionJavaType(java.lang.Class clazz,
                          JDOModel jdoModel)
Constructor.

Method Detail

isArray

public boolean isArray()
Determines if this JavaType object represents an array type.

Specified by:
isArray in interface JavaType
Overrides:
isArray in class AbstractJavaType
Returns:
true if this object represents an array type; false otherwise.

isPersistenceCapable

public boolean isPersistenceCapable()
                             throws ModelFatalException
Returns true if this JavaType represents a persistence capable class.

A ModelFatalException indicates a problem accessing the JDO meta data for this JavaType.

Specified by:
isPersistenceCapable in interface JavaType
Overrides:
isPersistenceCapable in class AbstractJavaType
Returns:
true if this JavaType represents a persistence capable class; false otherwise.
Throws:
ModelFatalException - if there is a problem accessing the JDO metadata

getSuperclass

public JavaType getSuperclass()
Returns the JavaType representing the superclass of the entity represented by this JavaType. If this JavaType represents either the Object class, an interface, a primitive type, or void, then null is returned. If this object represents an array class then the JavaType instance representing the Object class is returned.

Specified by:
getSuperclass in interface JavaType
Overrides:
getSuperclass in class BaseReflectionJavaType
Returns:
the superclass of the class represented by this JavaType.

getJDOClass

public JDOClass getJDOClass()
                     throws ModelFatalException
Returns the JDOClass instance if this JavaType represents a persistence capable class. The method returns null, if this JavaType does not represent a persistence capable class.

A ModelFatalException indicates a problem accessing the JDO meta data for this JavaType.

Specified by:
getJDOClass in interface JavaType
Overrides:
getJDOClass in class AbstractJavaType
Returns:
the JDOClass instance if this JavaType represents a persistence capable class; null otherwise.
Throws:
ModelFatalException - if there is a problem accessing the JDO metadata

getArrayComponentType

public JavaType getArrayComponentType()
Returns the JavaType representing the component type of an array. If this JavaType does not represent an array type this method returns null.

Specified by:
getArrayComponentType in interface JavaType
Overrides:
getArrayComponentType in class AbstractJavaType
Returns:
the JavaType representing the component type of this JavaType if this class is an array; null otherwise.

getJavaField

public JavaField getJavaField(java.lang.String fieldName)
Returns a JavaField instance that reflects the field with the specified name of the class or interface represented by this JavaType instance. The method returns null, if the class or interface (or one of its superclasses) does not have a field with that name.

Specified by:
getJavaField in interface JavaType
Overrides:
getJavaField in class BaseReflectionJavaType
Parameters:
fieldName - the name of the field
Returns:
the JavaField instance for the specified field in this class or null if there is no such field.

createJavaField

public JavaField createJavaField(JDOField jdoField,
                                 JavaType type)
RegisterClassListener calls this method to create a ReflectionJavaField instance when processing the enhancer generated metadata.

Parameters:
jdoField - the JDO field metadata
type - the type of the field
Returns:
the ReflectionJavaField representation

getDeclaredJavaField

public JavaField getDeclaredJavaField(java.lang.String fieldName)
Returns a JavaField instance that reflects the declared field with the specified name of the class or interface represented by this JavaType instance. The method returns null, if the class or interface does not declared a field with that name. It does not check whether one of its superclasses declared such a field.

Parameters:
fieldName - the name of the field
Returns:
the JavaField instance for the specified field in this class

getJavaTypeInternal

protected abstract JavaType getJavaTypeInternal(java.lang.Class clazz)
Returns a JavaType instance for the specified Class object. This method provides a hook such that ReflectionJavaType subclasses can implement their own mapping of Class objects to JavaType instances.



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