java.lang.reflect.Field Class Reference

Inheritance diagram for java.lang.reflect.Field:

java.lang.reflect.AccessibleObject

List of all members.


Detailed Description

This class must be implemented by the VM vendor.

This class models a field. Information about the field can be accessed, and the field's value can be accessed dynamically.

Public Member Functions

boolean isSynthetic ()
String toGenericString ()
boolean isEnumConstant ()
Type getGenericType ()
boolean equals (Object object)
 Compares the specified object to this Field and answer if they are equal.
native Object get (Object object) throws IllegalAccessException, IllegalArgumentException
 Return the value of the field in the specified object.
native boolean getBoolean (Object object) throws IllegalAccessException, IllegalArgumentException
 Return the value of the field in the specified object as a boolean.
native byte getByte (Object object) throws IllegalAccessException, IllegalArgumentException
 Return the value of the field in the specified object as a byte.
native char getChar (Object object) throws IllegalAccessException, IllegalArgumentException
 Return the value of the field in the specified object as a char.
Class<?> getDeclaringClass ()
 Return the Class associated with the class that defined this field.
native double getDouble (Object object) throws IllegalAccessException, IllegalArgumentException
 Return the value of the field in the specified object as a double.
native float getFloat (Object object) throws IllegalAccessException, IllegalArgumentException
 Return the value of the field in the specified object as a float.
native int getInt (Object object) throws IllegalAccessException, IllegalArgumentException
 Return the value of the field in the specified object as an int.
native long getLong (Object object) throws IllegalAccessException, IllegalArgumentException
 Return the value of the field in the specified object as a long.
native int getModifiers ()
 Return the modifiers for the modeled field.
String getName ()
 Return the name of the modeled field.
native short getShort (Object object) throws IllegalAccessException, IllegalArgumentException
 Return the value of the field in the specified object as a short.
Class<?> getType ()
 Return the Class associated with the type of this field.
int hashCode ()
 Answers an integer hash code for the receiver.
native void set (Object object, Object value) throws IllegalAccessException, IllegalArgumentException
 Set the value of the field in the specified object to the boolean value.
native void setBoolean (Object object, boolean value) throws IllegalAccessException, IllegalArgumentException
 Set the value of the field in the specified object to the boolean value.
native void setByte (Object object, byte value) throws IllegalAccessException, IllegalArgumentException
 Set the value of the field in the specified object to the byte value.
native void setChar (Object object, char value) throws IllegalAccessException, IllegalArgumentException
 Set the value of the field in the specified object to the char value.
native void setDouble (Object object, double value) throws IllegalAccessException, IllegalArgumentException
 Set the value of the field in the specified object to the double value.
native void setFloat (Object object, float value) throws IllegalAccessException, IllegalArgumentException
 Set the value of the field in the specified object to the float value.
native void setInt (Object object, int value) throws IllegalAccessException, IllegalArgumentException
 Set the value of the field in the specified object to the int value.
native void setLong (Object object, long value) throws IllegalAccessException, IllegalArgumentException
 Set the value of the field in the specified object to the long value.
native void setShort (Object object, short value) throws IllegalAccessException, IllegalArgumentException
 Set the value of the field in the specified object to the short value.
String toString ()
 Answers a string containing a concise, human-readable description of the receiver.

Package Functions

native String getSignature ()

Private Member Functions

 Field ()
 Prevent this class from being instantiated.


Constructor & Destructor Documentation

java.lang.reflect.Field.Field (  )  [private]

Prevent this class from being instantiated.


Member Function Documentation

native String java.lang.reflect.Field.getSignature (  )  [package]

TODO Document this method. Is it used?

Returns:
See also:
java.lang.reflect.AccessibleObject.getSignature()

Reimplemented from java.lang.reflect.AccessibleObject.

String java.lang.reflect.Field.toGenericString (  ) 

Returns the String representation of the field's declaration, including the type parameters.

Returns:
An instance of String.
Since:
1.5

boolean java.lang.reflect.Field.isEnumConstant (  ) 

Indicates whether or not this field is an enumeration constant.

Returns:
A value of true if this field is an enumeration constant, otherwise false.
Since:
1.5

Type java.lang.reflect.Field.getGenericType (  ) 

Gets the declared type of this field.

Returns:
An instance of Type.
Exceptions:
GenericSignatureFormatError if the generic method signature is invalid.
TypeNotPresentException if the component type points to a missing type.
MalformedParameterizedTypeException if the component type points to a type that can't be instantiated for some reason.
Since:
1.5

boolean java.lang.reflect.Field.equals ( Object  object  ) 

Compares the specified object to this Field and answer if they are equal.

The object must be an instance of Field with the same defining class and name.

Parameters:
object the object to compare
Returns:
true if the specified object is equal to this Field, false otherwise
See also:
hashCode

native Object java.lang.reflect.Field.get ( Object  object  )  throws IllegalAccessException, IllegalArgumentException

Return the value of the field in the specified object.

This reproduces the effect of object.fieldName

If the modeled field is static, the object argument is ignored. Otherwise, if the object is null, a NullPointerException is thrown. If the object is not an instance of the declaring class of the method, an IllegalArgumentException is thrown.

If this Field object is enforcing access control (see AccessibleObject) and the modeled field is not accessible from the current context, an IllegalAccessException is thrown.

The value of the field is returned. If the type of this field is a base type, the field value is automatically wrapped.

Parameters:
object the object to access
Returns:
the field value, possibly wrapped
Exceptions:
NullPointerException if the object is null and the field is non-static
IllegalArgumentException if the object is not compatible with the declaring class
IllegalAccessException if modeled field is not accessible

native boolean java.lang.reflect.Field.getBoolean ( Object  object  )  throws IllegalAccessException, IllegalArgumentException

Return the value of the field in the specified object as a boolean.

This reproduces the effect of object.fieldName

If the modeled field is static, the object argument is ignored. Otherwise, if the object is null, a NullPointerException is thrown. If the object is not an instance of the declaring class of the method, an IllegalArgumentException is thrown.

If this Field object is enforcing access control (see AccessibleObject) and the modeled field is not accessible from the current context, an IllegalAccessException is thrown.

Parameters:
object the object to access
Returns:
the field value
Exceptions:
NullPointerException if the object is null and the field is non-static
IllegalArgumentException if the object is not compatible with the declaring class
IllegalAccessException if modeled field is not accessible

native byte java.lang.reflect.Field.getByte ( Object  object  )  throws IllegalAccessException, IllegalArgumentException

Return the value of the field in the specified object as a byte.

This reproduces the effect of object.fieldName

If the modeled field is static, the object argument is ignored. Otherwise, if the object is null, a NullPointerException is thrown. If the object is not an instance of the declaring class of the method, an IllegalArgumentException is thrown.

If this Field object is enforcing access control (see AccessibleObject) and the modeled field is not accessible from the current context, an IllegalAccessException is thrown.

Parameters:
object the object to access
Returns:
the field value
Exceptions:
NullPointerException if the object is null and the field is non-static
IllegalArgumentException if the object is not compatible with the declaring class
IllegalAccessException if modeled field is not accessible

native char java.lang.reflect.Field.getChar ( Object  object  )  throws IllegalAccessException, IllegalArgumentException

Return the value of the field in the specified object as a char.

This reproduces the effect of object.fieldName

If the modeled field is static, the object argument is ignored. Otherwise, if the object is null, a NullPointerException is thrown. If the object is not an instance of the declaring class of the method, an IllegalArgumentException is thrown.

If this Field object is enforcing access control (see AccessibleObject) and the modeled field is not accessible from the current context, an IllegalAccessException is thrown.

Parameters:
object the object to access
Returns:
the field value
Exceptions:
NullPointerException if the object is null and the field is non-static
IllegalArgumentException if the object is not compatible with the declaring class
IllegalAccessException if modeled field is not accessible

Class<?> java.lang.reflect.Field.getDeclaringClass (  ) 

Return the Class associated with the class that defined this field.

Returns:
the declaring class

native double java.lang.reflect.Field.getDouble ( Object  object  )  throws IllegalAccessException, IllegalArgumentException

Return the value of the field in the specified object as a double.

This reproduces the effect of object.fieldName

If the modeled field is static, the object argument is ignored. Otherwise, if the object is null, a NullPointerException is thrown. If the object is not an instance of the declaring class of the method, an IllegalArgumentException is thrown.

If this Field object is enforcing access control (see AccessibleObject) and the modeled field is not accessible from the current context, an IllegalAccessException is thrown.

Parameters:
object the object to access
Returns:
the field value
Exceptions:
NullPointerException if the object is null and the field is non-static
IllegalArgumentException if the object is not compatible with the declaring class
IllegalAccessException if modeled field is not accessible

native float java.lang.reflect.Field.getFloat ( Object  object  )  throws IllegalAccessException, IllegalArgumentException

Return the value of the field in the specified object as a float.

This reproduces the effect of object.fieldName

If the modeled field is static, the object argument is ignored. Otherwise, if the object is null, a NullPointerException is thrown. If the object is not an instance of the declaring class of the method, an IllegalArgumentException is thrown.

If this Field object is enforcing access control (see AccessibleObject) and the modeled field is not accessible from the current context, an IllegalAccessException is thrown.

Parameters:
object the object to access
Returns:
the field value
Exceptions:
NullPointerException if the object is null and the field is non-static
IllegalArgumentException if the object is not compatible with the declaring class
IllegalAccessException if modeled field is not accessible

native int java.lang.reflect.Field.getInt ( Object  object  )  throws IllegalAccessException, IllegalArgumentException

Return the value of the field in the specified object as an int.

This reproduces the effect of object.fieldName

If the modeled field is static, the object argument is ignored. Otherwise, if the object is null, a NullPointerException is thrown. If the object is not an instance of the declaring class of the method, an IllegalArgumentException is thrown.

If this Field object is enforcing access control (see AccessibleObject) and the modeled field is not accessible from the current context, an IllegalAccessException is thrown.

Parameters:
object the object to access
Returns:
the field value
Exceptions:
NullPointerException if the object is null and the field is non-static
IllegalArgumentException if the object is not compatible with the declaring class
IllegalAccessException if modeled field is not accessible

native long java.lang.reflect.Field.getLong ( Object  object  )  throws IllegalAccessException, IllegalArgumentException

Return the value of the field in the specified object as a long.

This reproduces the effect of object.fieldName

If the modeled field is static, the object argument is ignored. Otherwise, if the object is null, a NullPointerException is thrown. If the object is not an instance of the declaring class of the method, an IllegalArgumentException is thrown.

If this Field object is enforcing access control (see AccessibleObject) and the modeled field is not accessible from the current context, an IllegalAccessException is thrown.

Parameters:
object the object to access
Returns:
the field value
Exceptions:
NullPointerException if the object is null and the field is non-static
IllegalArgumentException if the object is not compatible with the declaring class
IllegalAccessException if modeled field is not accessible

native int java.lang.reflect.Field.getModifiers (  ) 

Return the modifiers for the modeled field.

The Modifier class should be used to decode the result.

Returns:
the modifiers
See also:
java.lang.reflect.Modifier

Reimplemented from java.lang.reflect.AccessibleObject.

String java.lang.reflect.Field.getName (  ) 

Return the name of the modeled field.

Returns:
the name

native short java.lang.reflect.Field.getShort ( Object  object  )  throws IllegalAccessException, IllegalArgumentException

Return the value of the field in the specified object as a short.

This reproduces the effect of object.fieldName

If the modeled field is static, the object argument is ignored. Otherwise, if the object is null, a NullPointerException is thrown. If the object is not an instance of the declaring class of the method, an IllegalArgumentException is thrown.

If this Field object is enforcing access control (see AccessibleObject) and the modeled field is not accessible from the current context, an IllegalAccessException is thrown.

Parameters:
object the object to access
Returns:
the field value
Exceptions:
NullPointerException if the object is null and the field is non-static
IllegalArgumentException if the object is not compatible with the declaring class
IllegalAccessException if modeled field is not accessible

Class<?> java.lang.reflect.Field.getType (  ) 

Return the Class associated with the type of this field.

Returns:
the type

int java.lang.reflect.Field.hashCode (  ) 

Answers an integer hash code for the receiver.

Objects which are equal answer the same value for this method.

The hash code for a Field is the hash code of the field's name.

Returns:
the receiver's hash
See also:
equals

native void java.lang.reflect.Field.set ( Object  object,
Object  value 
) throws IllegalAccessException, IllegalArgumentException

Set the value of the field in the specified object to the boolean value.

This reproduces the effect of object.fieldName = value

If the modeled field is static, the object argument is ignored. Otherwise, if the object is null, a NullPointerException is thrown. If the object is not an instance of the declaring class of the method, an IllegalArgumentException is thrown.

If this Field object is enforcing access control (see AccessibleObject) and the modeled field is not accessible from the current context, an IllegalAccessException is thrown.

If the field type is a base type, the value is automatically unwrapped. If the unwrap fails, an IllegalArgumentException is thrown. If the value cannot be converted to the field type via a widening conversion, an IllegalArgumentException is thrown.

Parameters:
object the object to access
value the new value
Exceptions:
NullPointerException if the object is null and the field is non-static
IllegalArgumentException if the object is not compatible with the declaring class
IllegalAccessException if modeled field is not accessible

native void java.lang.reflect.Field.setBoolean ( Object  object,
boolean  value 
) throws IllegalAccessException, IllegalArgumentException

Set the value of the field in the specified object to the boolean value.

This reproduces the effect of object.fieldName = value

If the modeled field is static, the object argument is ignored. Otherwise, if the object is null, a NullPointerException is thrown. If the object is not an instance of the declaring class of the method, an IllegalArgumentException is thrown.

If this Field object is enforcing access control (see AccessibleObject) and the modeled field is not accessible from the current context, an IllegalAccessException is thrown.

If the value cannot be converted to the field type via a widening conversion, an IllegalArgumentException is thrown.

Parameters:
object the object to access
value the new value
Exceptions:
NullPointerException if the object is null and the field is non-static
IllegalArgumentException if the object is not compatible with the declaring class
IllegalAccessException if modeled field is not accessible

native void java.lang.reflect.Field.setByte ( Object  object,
byte  value 
) throws IllegalAccessException, IllegalArgumentException

Set the value of the field in the specified object to the byte value.

This reproduces the effect of object.fieldName = value

If the modeled field is static, the object argument is ignored. Otherwise, if the object is null, a NullPointerException is thrown. If the object is not an instance of the declaring class of the method, an IllegalArgumentException is thrown.

If this Field object is enforcing access control (see AccessibleObject) and the modeled field is not accessible from the current context, an IllegalAccessException is thrown.

If the value cannot be converted to the field type via a widening conversion, an IllegalArgumentException is thrown.

Parameters:
object the object to access
value the new value
Exceptions:
NullPointerException if the object is null and the field is non-static
IllegalArgumentException if the object is not compatible with the declaring class
IllegalAccessException if modeled field is not accessible

native void java.lang.reflect.Field.setChar ( Object  object,
char  value 
) throws IllegalAccessException, IllegalArgumentException

Set the value of the field in the specified object to the char value.

This reproduces the effect of object.fieldName = value

If the modeled field is static, the object argument is ignored. Otherwise, if the object is null, a NullPointerException is thrown. If the object is not an instance of the declaring class of the method, an IllegalArgumentException is thrown.

If this Field object is enforcing access control (see AccessibleObject) and the modeled field is not accessible from the current context, an IllegalAccessException is thrown.

If the value cannot be converted to the field type via a widening conversion, an IllegalArgumentException is thrown.

Parameters:
object the object to access
value the new value
Exceptions:
NullPointerException if the object is null and the field is non-static
IllegalArgumentException if the object is not compatible with the declaring class
IllegalAccessException if modeled field is not accessible

native void java.lang.reflect.Field.setDouble ( Object  object,
double  value 
) throws IllegalAccessException, IllegalArgumentException

Set the value of the field in the specified object to the double value.

This reproduces the effect of object.fieldName = value

If the modeled field is static, the object argument is ignored. Otherwise, if the object is null, a NullPointerException is thrown. If the object is not an instance of the declaring class of the method, an IllegalArgumentException is thrown.

If this Field object is enforcing access control (see AccessibleObject) and the modeled field is not accessible from the current context, an IllegalAccessException is thrown.

If the value cannot be converted to the field type via a widening conversion, an IllegalArgumentException is thrown.

Parameters:
object the object to access
value the new value
Exceptions:
NullPointerException if the object is null and the field is non-static
IllegalArgumentException if the object is not compatible with the declaring class
IllegalAccessException if modeled field is not accessible

native void java.lang.reflect.Field.setFloat ( Object  object,
float  value 
) throws IllegalAccessException, IllegalArgumentException

Set the value of the field in the specified object to the float value.

This reproduces the effect of object.fieldName = value

If the modeled field is static, the object argument is ignored. Otherwise, if the object is null, a NullPointerException is thrown. If the object is not an instance of the declaring class of the method, an IllegalArgumentException is thrown.

If this Field object is enforcing access control (see AccessibleObject) and the modeled field is not accessible from the current context, an IllegalAccessException is thrown.

If the value cannot be converted to the field type via a widening conversion, an IllegalArgumentException is thrown.

Parameters:
object the object to access
value the new value
Exceptions:
NullPointerException if the object is null and the field is non-static
IllegalArgumentException if the object is not compatible with the declaring class
IllegalAccessException if modeled field is not accessible

native void java.lang.reflect.Field.setInt ( Object  object,
int  value 
) throws IllegalAccessException, IllegalArgumentException

Set the value of the field in the specified object to the int value.

This reproduces the effect of object.fieldName = value

If the modeled field is static, the object argument is ignored. Otherwise, if the object is null, a NullPointerException is thrown. If the object is not an instance of the declaring class of the method, an IllegalArgumentException is thrown.

If this Field object is enforcing access control (see AccessibleObject) and the modeled field is not accessible from the current context, an IllegalAccessException is thrown.

If the value cannot be converted to the field type via a widening conversion, an IllegalArgumentException is thrown.

Parameters:
object the object to access
value the new value
Exceptions:
NullPointerException if the object is null and the field is non-static
IllegalArgumentException if the object is not compatible with the declaring class
IllegalAccessException if modeled field is not accessible

native void java.lang.reflect.Field.setLong ( Object  object,
long  value 
) throws IllegalAccessException, IllegalArgumentException

Set the value of the field in the specified object to the long value.

This reproduces the effect of object.fieldName = value

If the modeled field is static, the object argument is ignored. Otherwise, if the object is null, a NullPointerException is thrown. If the object is not an instance of the declaring class of the method, an IllegalArgumentException is thrown.

If this Field object is enforcing access control (see AccessibleObject) and the modeled field is not accessible from the current context, an IllegalAccessException is thrown.

If the value cannot be converted to the field type via a widening conversion, an IllegalArgumentException is thrown.

Parameters:
object the object to access
value the new value
Exceptions:
NullPointerException if the object is null and the field is non-static
IllegalArgumentException if the object is not compatible with the declaring class
IllegalAccessException if modeled field is not accessible

native void java.lang.reflect.Field.setShort ( Object  object,
short  value 
) throws IllegalAccessException, IllegalArgumentException

Set the value of the field in the specified object to the short value.

This reproduces the effect of object.fieldName = value

If the modeled field is static, the object argument is ignored. Otherwise, if the object is null, a NullPointerException is thrown. If the object is not an instance of the declaring class of the method, an IllegalArgumentException is thrown.

If this Field object is enforcing access control (see AccessibleObject) and the modeled field is not accessible from the current context, an IllegalAccessException is thrown.

If the value cannot be converted to the field type via a widening conversion, an IllegalArgumentException is thrown.

Parameters:
object the object to access
value the new value
Exceptions:
NullPointerException if the object is null and the field is non-static
IllegalArgumentException if the object is not compatible with the declaring class
IllegalAccessException if modeled field is not accessible

String java.lang.reflect.Field.toString (  ) 

Answers a string containing a concise, human-readable description of the receiver.

The format of the string is:

For example: public static java.io.InputStream java.lang.System.in

Returns:
a printable representation for the receiver


The documentation for this class was generated from the following file:

Genereated on Tue Dec 9 14:09:48 2008 by Doxygen.

(c) Copyright 2005, 2008 The Apache Software Foundation or its licensors, as applicable.