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

java.lang.Object
  extended by org.apache.jdo.impl.model.java.AbstractJavaMember
      extended by org.apache.jdo.impl.model.java.BaseReflectionJavaField
All Implemented Interfaces:
JavaElement, JavaField, JavaMember
Direct Known Subclasses:
ReflectionJavaField

public class BaseReflectionJavaField
extends AbstractJavaMember
implements JavaField

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
Version:
JDO 2.0
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 the specified field name.
static java.lang.reflect.Field[] getDeclaredFieldsPrivileged(java.lang.Class clazz)
          Helper method to retrieve the declared java.lang.reflect.Field instances for the specified class.
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.
 java.lang.Object getUnderlyingObject()
          Returns the environment specific instance wrapped by this JavaModel element.
 
Methods inherited from class org.apache.jdo.impl.model.java.AbstractJavaMember
equals, getComponentType, getDeclaringClass, getName, hashCode, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.jdo.model.java.JavaMember
getComponentType, getDeclaringClass, getName
 

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

getUnderlyingObject

public java.lang.Object getUnderlyingObject()
Returns the environment specific instance wrapped by this JavaModel element. This implementation returns the java.lang.reflect.Field instance for this JavaField.

Specified by:
getUnderlyingObject in interface JavaElement
Returns:
the environment specific instance wrapped by this JavaModel element.

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 JavaMember
Specified by:
getModifiers in class AbstractJavaMember
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 JavaMember
Specified by:
getType in class AbstractJavaMember
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 the specified field name.

Parameters:
clazz - the Class instance of the declaring class or interface
fieldName - the field name
Returns:
the java.lang.reflect.Field for the specified field name.

getDeclaredFieldsPrivileged

public static java.lang.reflect.Field[] getDeclaredFieldsPrivileged(java.lang.Class clazz)
Helper method to retrieve the declared java.lang.reflect.Field instances for the specified class.

Parameters:
clazz - the Class instance of the declaring class or interface
Returns:
the java.lang.reflect.Field instances for the declared fields of the specified class.

ensureInitializedField

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



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