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

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

public abstract class AbstractJavaField
extends java.lang.Object
implements JavaField

Abstract super class for JavaField implementations. It provides getters for the name and declaringClass properties which are initialized in the constructor. The implementation of method getJDOField always returns null.

A non-abstract subclass must implement methods getModifiers() and getType(). Note, this implementation of method getJDOField() always returns null, so a subclass may want to override this method.

Since:
JDO 1.0.1
Author:
Michael Bouschen

Constructor Summary
AbstractJavaField(java.lang.String name, JavaType declaringClass)
          Constructor setting the name and declaringClass property.
 
Method Summary
 boolean equals(java.lang.Object obj)
          Indicates whether some other object is "equal to" this one.
 JavaType getDeclaringClass()
          Returns the JavaType instance representing the class or interface that declares the field represented by this JavaField instance.
 JDOField getJDOField()
          Returns the corresponding JDOField instance, if the JDOModel provides any JDO metadata for the field represented by this JavaField.
abstract  int getModifiers()
          Returns the Java language modifiers for the field represented by this JavaField, as an integer.
 java.lang.String getName()
          Returns the name of the field.
abstract  JavaType getType()
          Returns the JavaType representation of the field type.
 int hashCode()
          Returns a hash code value for the object.
 java.lang.String toString()
          Returns a string representation of the object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractJavaField

public AbstractJavaField(java.lang.String name,
                         JavaType declaringClass)
Constructor setting the name and declaringClass property.

Parameters:
name - field name
declaringClass - the JavaType of the class or interface that declares this JavaField.
Method Detail

getName

public java.lang.String getName()
Returns the name of the field.

Specified by:
getName in interface JavaField
Returns:
field name

getModifiers

public abstract 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
Returns:
the Java language modifiers for this JavaField
See Also:
Modifier

getType

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

Specified by:
getType in interface JavaField
Returns:
field type

getDeclaringClass

public JavaType getDeclaringClass()
Returns the JavaType instance representing the class or interface that declares the field represented by this JavaField instance.

Specified by:
getDeclaringClass in interface JavaField
Returns:
the JavaType instance of the declaring class.

getJDOField

public JDOField getJDOField()
Returns the corresponding JDOField instance, if the JDOModel provides any JDO metadata for the field represented by this JavaField. If there is no corresponding JDOField representation, the method returns null.

This implementation always returns null.

Specified by:
getJDOField in interface JavaField
Returns:
the corresponding JDOField instance (if available); null otherwise.

equals

public boolean equals(java.lang.Object obj)
Indicates whether some other object is "equal to" this one.

Overrides:
equals in class java.lang.Object
Parameters:
obj - the reference object with which to compare.

This implementation matches the declaring class and the name of the specified object to the declaring class and the name of this JavaField.

Returns:
true if this object is the same as the obj argument; false otherwise.

hashCode

public int hashCode()
Returns a hash code value for the object.

This is computed as the exclusive-or of the hashcodes for the underlying field's declaring class name and its name.

Overrides:
hashCode in class java.lang.Object
Returns:
a hash code value for this object.

toString

public java.lang.String toString()
Returns a string representation of the object.

Overrides:
toString in class java.lang.Object
Returns:
a string representation of the object.


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