aicas logoJamaica 3.2 release 62

java.lang.reflect
Class Field

java.lang.Object
  extended by java.lang.reflect.AccessibleObject
      extended by java.lang.reflect.Field
All Implemented Interfaces:
AnnotatedElement, Member

public final class Field
extends AccessibleObject
implements AnnotatedElement, Member

Field enables reflection access to Java fields.


Field Summary
 
Fields inherited from interface java.lang.reflect.Member
DECLARED, PUBLIC
 
Method Summary
 boolean equals(Object obj)
          equals checks if this field is equal to another field.
 Object get(Object obj)
          get returns the value of this field.
<T extends Annotation>
T
getAnnotation(Class<T> annotationType)
          getAnnotation NYI: COMMENT: JDK 1.5 method description
 boolean getBoolean(Object obj)
          getBoolean returns the value of this boolean field.
 byte getByte(Object obj)
          getByte returns the value of this byte field.
 char getChar(Object obj)
          getChar returns the value of this char field.
 Annotation[] getDeclaredAnnotations()
          getDeclaredAnnotations NYI: COMMENT: JDK 1.5 method description
 Class<?> getDeclaringClass()
          getDeclaringClass returns the class this field was declared in.
 double getDouble(Object obj)
          getDouble returns the value of this doublue field.
 float getFloat(Object obj)
          getFloat returns the value of this float field.
 Type getGenericType()
          getGenericType NYI: COMMENT: JDK 1.5 method description
 int getInt(Object obj)
          getInt returns the value of this int field.
 long getLong(Object obj)
          getLong returns the value of this long field.
 int getModifiers()
          getModifiers returns the set of modifiers set for this field.
 String getName()
          getName returns the name of this field.
 short getShort(Object obj)
          getShort returns the value of this short field.
 Class<?> getType()
          getType returns the type of this field.
 int hashCode()
          hashCode returns a hash code for this field
 boolean isEnumConstant()
          isEnumConstant NYI: COMMENT: JDK 1.5 method description
 boolean isSynthetic()
          isSynthetic NYI: COMMENT: JDK 1.5 method description
 void set(Object o, Object v)
          set sets the value of this field.
 void setBoolean(Object obj, boolean z)
          setBoolean sets the value of this field.
 void setByte(Object obj, byte b)
          setByte sets the value of this field.
 void setChar(Object obj, char c)
          setChar sets the value of this field.
 void setDouble(Object obj, double d)
          setDouble sets the value of this field.
 void setFloat(Object obj, float f)
          setFloat sets the value of this field.
 void setInt(Object obj, int i)
          setInt sets the value of this field.
 void setLong(Object obj, long l)
          setLong sets the value of this field.
 void setShort(Object obj, short s)
          setShort sets the value of this field.
 String toGenericString()
          toGenericString NYI: COMMENT: JDK 1.5 method description
 String toString()
          toString converts this field to a string such as "public java.io.PrintStream java.lang.System.out".
 
Methods inherited from class java.lang.reflect.AccessibleObject
getAnnotations, isAccessible, isAnnotationPresent, setAccessible, setAccessible
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.lang.reflect.AnnotatedElement
getAnnotations, isAnnotationPresent
 

Method Detail

getDeclaringClass

public Class<?> getDeclaringClass()
getDeclaringClass returns the class this field was declared in.

Specified by:
getDeclaringClass in interface Member
Returns:
The class declaring this method.
See Also:
Member.getDeclaringClass()

getName

public String getName()
getName returns the name of this field.

Specified by:
getName in interface Member
Returns:
the name as a java string.

getModifiers

public int getModifiers()
getModifiers returns the set of modifiers set for this field.

Specified by:
getModifiers in interface Member
Returns:
the modifiers.
See Also:
Modifier

getType

public Class<?> getType()
getType returns the type of this field.

Returns:
the type, either a Java class, an array type or a primitive type such as Integer.TYPE.

equals

public boolean equals(Object obj)
equals checks if this field is equal to another field.

Overrides:
equals in class Object
Parameters:
obj - another object
Returns:
true iff obj is a field with the same declaring class, equal name and same type as this.

hashCode

public int hashCode()
hashCode returns a hash code for this field

Overrides:
hashCode in class Object
Returns:
getDeclaringClass().getName().hashCode() ^ getName().hashCode()

toString

public String toString()
toString converts this field to a string such as "public java.io.PrintStream java.lang.System.out".

Overrides:
toString in class Object
Returns:
a string representation of this field.

get

public Object get(Object obj)
           throws IllegalArgumentException,
                  IllegalAccessException
get returns the value of this field. If this field's declaring class is static and is not initialized, this class will be initialized first.

Parameters:
obj - the instance to take this value from in case of an instance field. Ignored in case of a static field access.
Returns:
the value of this field, boxed in case it is a primitive type.
Throws:
IllegalArgumentException - if this is an instance field and obj is not an instance of getDeclaringClass().
IllegalAccessException - if the caller does not have the right to access this field.
NullPointerException - if this is an instance field and obj is null.
ExceptionInInitializerError - if this is a static field and initialization of the declaring class failed.

getBoolean

public boolean getBoolean(Object obj)
                   throws IllegalArgumentException,
                          IllegalAccessException
getBoolean returns the value of this boolean field. If this field's declaring class is static and is not initialized, this class will be initialized first.

Parameters:
obj - the instance to take this value from in case of an instance field. Ignored in case of a static field access.
Returns:
the value of this field.
Throws:
IllegalArgumentException - if this is an instance field and obj is not an instance of getDeclaringClass() or this field's type is not boolean.
IllegalAccessException - if the caller does not have the right to access this field.
NullPointerException - if this is an instance field and obj is null.
ExceptionInInitializerError - if this is a static field and initialization of the declaring class failed.

getByte

public byte getByte(Object obj)
             throws IllegalArgumentException,
                    IllegalAccessException
getByte returns the value of this byte field. If this field's declaring class is static and is not initialized, this class will be initialized first.

Parameters:
obj - the instance to take this value from in case of an instance field. Ignored in case of a static field access.
Returns:
the value of this field.
Throws:
IllegalArgumentException - if this is an instance field and obj is not an instance of getDeclaringClass() or this field's type is not byte.
IllegalAccessException - if the caller does not have the right to access this field.
NullPointerException - if this is an instance field and obj is null.
ExceptionInInitializerError - if this is a static field and initialization of the declaring class failed.

getChar

public char getChar(Object obj)
             throws IllegalArgumentException,
                    IllegalAccessException
getChar returns the value of this char field. If this field's declaring class is static and is not initialized, this class will be initialized first.

Parameters:
obj - the instance to take this value from in case of an instance field. Ignored in case of a static field access.
Returns:
the value of this field.
Throws:
IllegalArgumentException - if this is an instance field and obj is not an instance of getDeclaringClass() or this field's type is not char.
IllegalAccessException - if the caller does not have the right to access this field.
NullPointerException - if this is an instance field and obj is null.
ExceptionInInitializerError - if this is a static field and initialization of the declaring class failed.

getShort

public short getShort(Object obj)
               throws IllegalArgumentException,
                      IllegalAccessException
getShort returns the value of this short field. If this field's declaring class is static and is not initialized, this class will be initialized first.

Parameters:
obj - the instance to take this value from in case of an instance field. Ignored in case of a static field access.
Returns:
the value of this field.
Throws:
IllegalArgumentException - if this is an instance field and obj is not an instance of getDeclaringClass() or this field's type is not short.
IllegalAccessException - if the caller does not have the right to access this field.
NullPointerException - if this is an instance field and obj is null.
ExceptionInInitializerError - if this is a static field and initialization of the declaring class failed.

getInt

public int getInt(Object obj)
           throws IllegalArgumentException,
                  IllegalAccessException
getInt returns the value of this int field. If this field's declaring class is static and is not initialized, this class will be initialized first.

Parameters:
obj - the instance to take this value from in case of an instance field. Ignored in case of a static field access.
Returns:
the value of this field.
Throws:
IllegalArgumentException - if this is an instance field and obj is not an instance of getDeclaringClass() or this field's type is not int.
IllegalAccessException - if the caller does not have the right to access this field.
NullPointerException - if this is an instance field and obj is null.
ExceptionInInitializerError - if this is a static field and initialization of the declaring class failed.

getLong

public long getLong(Object obj)
             throws IllegalArgumentException,
                    IllegalAccessException
getLong returns the value of this long field. If this field's declaring class is static and is not initialized, this class will be initialized first.

Parameters:
obj - the instance to take this value from in case of an instance field. Ignored in case of a static field access.
Returns:
the value of this field.
Throws:
IllegalArgumentException - if this is an instance field and obj is not an instance of getDeclaringClass() or this field's type is not long.
IllegalAccessException - if the caller does not have the right to access this field.
NullPointerException - if this is an instance field and obj is null.
ExceptionInInitializerError - if this is a static field and initialization of the declaring class failed.

getFloat

public float getFloat(Object obj)
               throws IllegalArgumentException,
                      IllegalAccessException
getFloat returns the value of this float field. If this field's declaring class is static and is not initialized, this class will be initialized first.

Parameters:
obj - the instance to take this value from in case of an instance field. Ignored in case of a static field access.
Returns:
the value of this field.
Throws:
IllegalArgumentException - if this is an instance field and obj is not an instance of getDeclaringClass() or this field's type is not float.
IllegalAccessException - if the caller does not have the right to access this field.
NullPointerException - if this is an instance field and obj is null.
ExceptionInInitializerError - if this is a static field and initialization of the declaring class failed.

getDouble

public double getDouble(Object obj)
                 throws IllegalArgumentException,
                        IllegalAccessException
getDouble returns the value of this doublue field. If this field's declaring class is static and is not initialized, this class will be initialized first.

Parameters:
obj - the instance to take this value from in case of an instance field. Ignored in case of a static field access.
Returns:
the value of this field.
Throws:
IllegalArgumentException - if this is an instance field and obj is not an instance of getDeclaringClass() or this field's type is not double.
IllegalAccessException - if the caller does not have the right to access this field.
NullPointerException - if this is an instance field and obj is null.
ExceptionInInitializerError - if this is a static field and initialization of the declaring class failed.

set

public void set(Object o,
                Object v)
         throws IllegalArgumentException,
                IllegalAccessException
set sets the value of this field. If this field's declaring class is static and is not initialized, this class will be initialized first.

Parameters:
o - the instance containing the field to be set in case of an instance field. Ignored in case of a static field access.
v - the new value of the field, boxed in case a field of primitive type is set.
Throws:
IllegalArgumentException - if this is an instance field and o is not an instance of getDeclaringClass() or if value could not be converted to the field type with a widening conversion.
IllegalAccessException - if the caller does not have the right to access this field.
NullPointerException - if this is an instance field and o is null.
ExceptionInInitializerError - if this is a static field and initialization of the declaring class failed.

setBoolean

public void setBoolean(Object obj,
                       boolean z)
                throws IllegalArgumentException,
                       IllegalAccessException
setBoolean sets the value of this field. If this field's declaring class is static and is not initialized, this class will be initialized first.

Parameters:
obj - the instance containing the field to be set in case of an instance field. Ignored in case of a static field access.
z - the new value of the field.
Throws:
IllegalArgumentException - if this is an instance field and o is not an instance of getDeclaringClass() or if this field's type is not boolean.
IllegalAccessException - if the caller does not have the right to access this field.
NullPointerException - if this is an instance field and o is null.
ExceptionInInitializerError - if this is a static field and initialization of the declaring class failed.

setByte

public void setByte(Object obj,
                    byte b)
             throws IllegalArgumentException,
                    IllegalAccessException
setByte sets the value of this field. If this field's declaring class is static and is not initialized, this class will be initialized first.

Parameters:
obj - the instance containing the field to be set in case of an instance field. Ignored in case of a static field access.
b - the new value of the field.
Throws:
IllegalArgumentException - if this is an instance field and o is not an instance of getDeclaringClass() or if this field's type is not byte.
IllegalAccessException - if the caller does not have the right to access this field.
NullPointerException - if this is an instance field and o is null.
ExceptionInInitializerError - if this is a static field and initialization of the declaring class failed.

setChar

public void setChar(Object obj,
                    char c)
             throws IllegalArgumentException,
                    IllegalAccessException
setChar sets the value of this field. If this field's declaring class is static and is not initialized, this class will be initialized first.

Parameters:
obj - the instance containing the field to be set in case of an instance field. Ignored in case of a static field access.
c - the new value of the field.
Throws:
IllegalArgumentException - if this is an instance field and o is not an instance of getDeclaringClass() or if this field's type is not char.
IllegalAccessException - if the caller does not have the right to access this field.
NullPointerException - if this is an instance field and o is null.
ExceptionInInitializerError - if this is a static field and initialization of the declaring class failed.

setShort

public void setShort(Object obj,
                     short s)
              throws IllegalArgumentException,
                     IllegalAccessException
setShort sets the value of this field. If this field's declaring class is static and is not initialized, this class will be initialized first.

Parameters:
obj - the instance containing the field to be set in case of an instance field. Ignored in case of a static field access.
s - the new value of the field.
Throws:
IllegalArgumentException - if this is an instance field and o is not an instance of getDeclaringClass() or if this field's type is not short.
IllegalAccessException - if the caller does not have the right to access this field.
NullPointerException - if this is an instance field and o is null.
ExceptionInInitializerError - if this is a static field and initialization of the declaring class failed.

setInt

public void setInt(Object obj,
                   int i)
            throws IllegalArgumentException,
                   IllegalAccessException
setInt sets the value of this field. If this field's declaring class is static and is not initialized, this class will be initialized first.

Parameters:
obj - the instance containing the field to be set in case of an instance field. Ignored in case of a static field access.
i - the new value of the field.
Throws:
IllegalArgumentException - if this is an instance field and o is not an instance of getDeclaringClass() or if this field's type is not int.
IllegalAccessException - if the caller does not have the right to access this field.
NullPointerException - if this is an instance field and o is null.
ExceptionInInitializerError - if this is a static field and initialization of the declaring class failed.

setLong

public void setLong(Object obj,
                    long l)
             throws IllegalArgumentException,
                    IllegalAccessException
setLong sets the value of this field. If this field's declaring class is static and is not initialized, this class will be initialized first.

Parameters:
obj - the instance containing the field to be set in case of an instance field. Ignored in case of a static field access.
l - the new value of the field.
Throws:
IllegalArgumentException - if this is an instance field and o is not an instance of getDeclaringClass() or if this field's type is not long.
IllegalAccessException - if the caller does not have the right to access this field.
NullPointerException - if this is an instance field and o is null.
ExceptionInInitializerError - if this is a static field and initialization of the declaring class failed.

setFloat

public void setFloat(Object obj,
                     float f)
              throws IllegalArgumentException,
                     IllegalAccessException
setFloat sets the value of this field. If this field's declaring class is static and is not initialized, this class will be initialized first.

Parameters:
obj - the instance containing the field to be set in case of an instance field. Ignored in case of a static field access.
f - the new value of the field.
Throws:
IllegalArgumentException - if this is an instance field and o is not an instance of getDeclaringClass() or if this field's type is not float.
IllegalAccessException - if the caller does not have the right to access this field.
NullPointerException - if this is an instance field and o is null.
ExceptionInInitializerError - if this is a static field and initialization of the declaring class failed.

setDouble

public void setDouble(Object obj,
                      double d)
               throws IllegalArgumentException,
                      IllegalAccessException
setDouble sets the value of this field. If this field's declaring class is static and is not initialized, this class will be initialized first.

Parameters:
obj - the instance containing the field to be set in case of an instance field. Ignored in case of a static field access.
d - the new value of the field.
Throws:
IllegalArgumentException - if this is an instance field and o is not an instance of getDeclaringClass() or if this field's type is not double.
IllegalAccessException - if the caller does not have the right to access this field.
NullPointerException - if this is an instance field and o is null.
ExceptionInInitializerError - if this is a static field and initialization of the declaring class failed.

isEnumConstant

public boolean isEnumConstant()
isEnumConstant

NYI: COMMENT: JDK 1.5 method description

Returns:
true if and only if this field represents an element of an enumerated type.
Since:
1.5

isSynthetic

public boolean isSynthetic()
isSynthetic

NYI: COMMENT: JDK 1.5 method description

Specified by:
isSynthetic in interface Member
Returns:
true if and only if this field is a synthetic field as defined by the Java Language Specification.
Since:
1.5

getGenericType

public Type getGenericType()
getGenericType

NYI: COMMENT: JDK 1.5 method description

Returns:
a Type object that represents the declared type for the field represented by this Field object
Since:
1.5

toGenericString

public String toGenericString()
toGenericString

NYI: COMMENT: JDK 1.5 method description

Returns:
a string describing this Field, including its generic type
Since:
1.5

getAnnotation

public <T extends Annotation> T getAnnotation(Class<T> annotationType)
getAnnotation

NYI: COMMENT: JDK 1.5 method description

Specified by:
getAnnotation in interface AnnotatedElement
Overrides:
getAnnotation in class AccessibleObject
Parameters:
annotationType -
Returns:
this element's annotation for the specified annotation type if present on this element, else null
Since:
1.5

getDeclaredAnnotations

public Annotation[] getDeclaredAnnotations()
getDeclaredAnnotations

NYI: COMMENT: JDK 1.5 method description

Specified by:
getDeclaredAnnotations in interface AnnotatedElement
Overrides:
getDeclaredAnnotations in class AccessibleObject
Returns:
All annotations directly present on this element
Since:
1.5

aicas logoJamaica 3.2 release 62

aicas GmbH, Karlsruhe - Germany    www.aicas.com
Copyright 2001-2008 aicas GmbH. All Rights Reserved.