org.apache.jdo.impl.model.java
Class BaseReflectionJavaField

java.lang.Object
  extended byorg.apache.jdo.impl.model.java.AbstractJavaField
      extended byorg.apache.jdo.impl.model.java.BaseReflectionJavaField
All Implemented Interfaces:
JavaField
Direct Known Subclasses:
ReflectionJavaField

public class BaseReflectionJavaField
extends AbstractJavaField

This class provides a basic JavaField implementation using a reflection Field instance. The implementation supports lazy initialization of the wrapped reflection field instance (see BaseReflectionJavaField(String fieldName, JavaType declaringClass).

Note, this implementation is not connected to a JavaModelFactory, thus it can only support predefined types as field types.

Since:
JDO 1.1
Author:
Michael Bouschen
See Also:
PredefinedType

Field Summary
protected  JavaType type
          The type of the field.
 
Constructor Summary
protected BaseReflectionJavaField(java.lang.reflect.Field field, JavaType declaringClass)
          Constructor taking a reflection field representation.
protected BaseReflectionJavaField(java.lang.String fieldName, JavaType declaringClass)
          Constructor taking the field name.
 
Method Summary
protected  void ensureInitializedField()
          This method makes sure the reflection field is set.
static java.lang.reflect.Field getDeclaredFieldPrivileged(java.lang.Class clazz, java.lang.String fieldName)
          Helper method to retrieve the java.lang.reflect.Field for this JavaField.
protected  java.lang.reflect.Field getField()
          Returns the java.lang.reflect.Field that is wrapped by this JavaField.
 int getModifiers()
          Returns the Java language modifiers for the field represented by this JavaField, as an integer.
 JavaType getType()
          Returns the JavaType representation of the field type.
 
Methods inherited from class org.apache.jdo.impl.model.java.AbstractJavaField
equals, getDeclaringClass, getJDOField, getName, hashCode, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

type

protected JavaType type
The type of the field.

Constructor Detail

BaseReflectionJavaField

protected BaseReflectionJavaField(java.lang.reflect.Field field,
                                  JavaType declaringClass)
Constructor taking a reflection field representation. The specifie field must not be null.

Parameters:
field - the java.lang.reflect.Field instance
declaringClass - the JavaType of the declaring class or interface.

BaseReflectionJavaField

protected BaseReflectionJavaField(java.lang.String fieldName,
                                  JavaType declaringClass)
Constructor taking the field name. This constructor allows lazy initialization of the field reference.

Parameters:
fieldName - the name of the field.
declaringClass - the JavaType of the declaring class or interface.
Method Detail

getModifiers

public int getModifiers()
Returns the Java language modifiers for the field represented by this JavaField, as an integer. The java.lang.reflect.Modifier class should be used to decode the modifiers.

Specified by:
getModifiers in interface JavaField
Specified by:
getModifiers in class AbstractJavaField
Returns:
the Java language modifiers for this JavaField
See Also:
Modifier

getType

public JavaType getType()
Returns the JavaType representation of the field type.

Specified by:
getType in interface JavaField
Specified by:
getType in class AbstractJavaField
Returns:
field type

getField

protected java.lang.reflect.Field getField()
Returns the java.lang.reflect.Field that is wrapped by this JavaField.

Returns:
the java.lang.reflect.Field instance.

getDeclaredFieldPrivileged

public static java.lang.reflect.Field getDeclaredFieldPrivileged(java.lang.Class clazz,
                                                                 java.lang.String fieldName)
Helper method to retrieve the java.lang.reflect.Field for this JavaField.

Parameters:
clazz - the Class instance of the declaring class or interface
fieldName - the field name

ensureInitializedField

protected void ensureInitializedField()
This method makes sure the reflection field is set.



Copyright © 2005 Apache Software Foundation. All Rights Reserved.