fr.umlv.corosol.component
Interface JField

All Superinterfaces:
JObject
All Known Implementing Classes:
DefaultJField

public interface JField
extends JObject

This interface represents a class field (static or not) and contains methods which permit to retrieve all informations about this field.

Author:
Christophe Deleray

Method Summary
 java.lang.Object get(JClassInstance object)
          Returns the value of the field represented by this Field, on the specified object.
 boolean getBoolean(JClassInstance object)
          Gets the value of a static or instance boolean field.
 byte getByte(JClassInstance object)
          Gets the value of a static or instance byte field.
 char getChar(JClassInstance object)
          Gets the value of a static or instance char field.
 JClass getDeclaringClass()
          Returns the JClass object representing the class or interface that declares the field represented by this JField object.
 java.lang.String getDescriptor()
          Returns the descriptor of the field represented by this JField object, as a String.
 double getDouble(JClassInstance object)
          Gets the value of a static or instance double field.
 float getFloat(JClassInstance object)
          Gets the value of a static or instance float field.
 int getInt(JClassInstance object)
          Gets the value of a static or instance int field.
 long getLong(JClassInstance object)
          Gets the value of a static or instance long field.
 int getModifiers()
          Returns the Java language modifiers for the field represented by this JField object, as an integer.
 java.lang.String getName()
          Returns the name of the field represented by this JField object.
 java.lang.reflect.Field getNativeField()
          Returns the java.lang.reflect.Field object equivalent to this JField object.
 short getShort(JClassInstance object)
          Gets the value of a static or instance short field.
 JClass getType()
          Returns a JClass object that identifies the declared type for the field represented by this JField object.
 boolean isStatic()
          Determines if the field specified by this JField object is static.
 void set(JClassInstance object, JHeapObject value)
          Sets the field represented by this JField object on the specified object argument to the specified new value.
 void setBoolean(JClassInstance object, boolean z)
          Sets the value of a field as a boolean on the specified object.
 void setByte(JClassInstance object, byte b)
          Sets the value of a field as a byte on the specified object.
 void setChar(JClassInstance object, char c)
          Sets the value of a field as a char on the specified object.
 void setDouble(JClassInstance object, double d)
          Sets the value of a field as a double on the specified object.
 void setFloat(JClassInstance object, float f)
          Sets the value of a field as a float on the specified object.
 void setInt(JClassInstance object, int i)
          Sets the value of a field as a int on the specified object.
 void setLong(JClassInstance object, long l)
          Sets the value of a field as a long on the specified object.
 void setShort(JClassInstance object, short s)
          Sets the value of a field as a short on the specified object.
 

Method Detail

getDeclaringClass

JClass getDeclaringClass()
Returns the JClass object representing the class or interface that declares the field represented by this JField object.

Returns:
the class declaring this field

getName

java.lang.String getName()
Returns the name of the field represented by this JField object.


getModifiers

int getModifiers()
Returns the Java language modifiers for the field represented by this JField object, as an integer. The Modifier class should be used to decode the modifiers.

See Also:
Modifier

getDescriptor

java.lang.String getDescriptor()
Returns the descriptor of the field represented by this JField object, as a String.


getType

JClass getType()
Returns a JClass object that identifies the declared type for the field represented by this JField object.

Returns:
a JClass object identifying the declared type of the field represented by this object

isStatic

boolean isStatic()
Determines if the field specified by this JField object is static.

Returns:
true if and only if this field is static; false otherwise.

get

java.lang.Object get(JClassInstance object)
                     throws java.lang.IllegalArgumentException,
                            java.lang.IllegalAccessException
Returns the value of the field represented by this Field, on the specified object. The value is automatically wrapped in an object if it has a primitive type.

Parameters:
object - object from which the represented field's value is to be extracted
Returns:
the value of the represented field in object obj; primitive values are wrapped in an appropriate object before being returned
Throws:
java.lang.IllegalAccessException - if the underlying field is inaccessible.
java.lang.IllegalArgumentException - if the specified object is not an instance of the class or interface declaring the underlying field (or a subclass or implementor thereof).
java.lang.NullPointerException - if the specified object is null and the field is an instance field.

getBoolean

boolean getBoolean(JClassInstance object)
                   throws java.lang.IllegalArgumentException,
                          java.lang.IllegalAccessException
Gets the value of a static or instance boolean field.

Parameters:
object - the object to extract the boolean value from
Returns:
the value of the boolean field
Throws:
java.lang.IllegalAccessException - if the underlying field is inaccessible.
java.lang.IllegalArgumentException - if the specified object is not an instance of the class or interface declaring the underlying field (or a subclass or implementor thereof), or if the field value cannot be converted to the type boolean by a widening conversion.
java.lang.NullPointerException - if the specified object is null and the field is an instance field.

getByte

byte getByte(JClassInstance object)
             throws java.lang.IllegalArgumentException,
                    java.lang.IllegalAccessException
Gets the value of a static or instance byte field.

Parameters:
object - the object to extract the byte value from
Returns:
the value of the byte field
Throws:
java.lang.IllegalAccessException - if the underlying field is inaccessible.
java.lang.IllegalArgumentException - if the specified object is not an instance of the class or interface declaring the underlying field (or a subclass or implementor thereof), or if the field value cannot be converted to the type byte by a widening conversion.
java.lang.NullPointerException - if the specified object is null and the field is an instance field.

getChar

char getChar(JClassInstance object)
             throws java.lang.IllegalArgumentException,
                    java.lang.IllegalAccessException
Gets the value of a static or instance char field.

Parameters:
object - the object to extract the char value from
Returns:
the value of the char field
Throws:
java.lang.IllegalAccessException - if the underlying field is inaccessible.
java.lang.IllegalArgumentException - if the specified object is not an instance of the class or interface declaring the underlying field (or a subclass or implementor thereof), or if the field value cannot be converted to the type char by a widening conversion.
java.lang.NullPointerException - if the specified object is null and the field is an instance field.

getShort

short getShort(JClassInstance object)
               throws java.lang.IllegalArgumentException,
                      java.lang.IllegalAccessException
Gets the value of a static or instance short field.

Parameters:
object - the object to extract the short value from
Returns:
the value of the short field
Throws:
java.lang.IllegalAccessException - if the underlying field is inaccessible.
java.lang.IllegalArgumentException - if the specified object is not an instance of the class or interface declaring the underlying field (or a subclass or implementor thereof), or if the field value cannot be converted to the type short by a widening conversion.
java.lang.NullPointerException - if the specified object is null and the field is an instance field.

getInt

int getInt(JClassInstance object)
           throws java.lang.IllegalArgumentException,
                  java.lang.IllegalAccessException
Gets the value of a static or instance int field.

Parameters:
object - the object to extract the int value from
Returns:
the value of the int field
Throws:
java.lang.IllegalAccessException - if the underlying field is inaccessible.
java.lang.IllegalArgumentException - if the specified object is not an instance of the class or interface declaring the underlying field (or a subclass or implementor thereof), or if the field value cannot be converted to the type int by a widening conversion.
java.lang.NullPointerException - if the specified object is null and the field is an instance field.

getLong

long getLong(JClassInstance object)
             throws java.lang.IllegalArgumentException,
                    java.lang.IllegalAccessException
Gets the value of a static or instance long field.

Parameters:
object - the object to extract the long value from
Returns:
the value of the long field
Throws:
java.lang.IllegalAccessException - if the underlying field is inaccessible.
java.lang.IllegalArgumentException - if the specified object is not an instance of the class or interface declaring the underlying field (or a subclass or implementor thereof), or if the field value cannot be converted to the type long by a widening conversion.
java.lang.NullPointerException - if the specified object is null and the field is an instance field.

getFloat

float getFloat(JClassInstance object)
               throws java.lang.IllegalArgumentException,
                      java.lang.IllegalAccessException
Gets the value of a static or instance float field.

Parameters:
object - the object to extract the float value from
Returns:
the value of the float field
Throws:
java.lang.IllegalAccessException - if the underlying field is inaccessible.
java.lang.IllegalArgumentException - if the specified object is not an instance of the class or interface declaring the underlying field (or a subclass or implementor thereof), or if the field value cannot be converted to the type float by a widening conversion.
java.lang.NullPointerException - if the specified object is null and the field is an instance field.

getDouble

double getDouble(JClassInstance object)
                 throws java.lang.IllegalArgumentException,
                        java.lang.IllegalAccessException
Gets the value of a static or instance double field.

Parameters:
object - the object to extract the double value from
Returns:
the value of the double field
Throws:
java.lang.IllegalAccessException - if the underlying field is inaccessible.
java.lang.IllegalArgumentException - if the specified object is not an instance of the class or interface declaring the underlying field (or a subclass or implementor thereof), or if the field value cannot be converted to the type double by a widening conversion.
java.lang.NullPointerException - if the specified object is null and the field is an instance field.

set

void set(JClassInstance object,
         JHeapObject value)
         throws java.lang.IllegalArgumentException,
                java.lang.IllegalAccessException
Sets the field represented by this JField object on the specified object argument to the specified new value. The new value is automatically unwrapped if the underlying field has a primitive type.

Parameters:
object - the object whose field should be modified
value - the new value for the field of obj being modified
Throws:
java.lang.IllegalAccessException - if the underlying field is inaccessible.
java.lang.IllegalArgumentException - if the specified object is not an instance of the class or interface declaring the underlying field (or a subclass or implementor thereof), or if an unwrapping conversion fails.
java.lang.NullPointerException - if the specified object is null and the field is an instance field.

setBoolean

void setBoolean(JClassInstance object,
                boolean z)
                throws java.lang.IllegalArgumentException,
                       java.lang.IllegalAccessException
Sets the value of a field as a boolean on the specified object. This method is equivalent to set(object, zObj), where zObj is a Boolean object and zObj.booleanValue() == z.

Parameters:
object - the object whose field should be modified
z - the new value for the field of obj being modified
Throws:
java.lang.IllegalAccessException - if the underlying field is inaccessible.
java.lang.IllegalArgumentException - if the specified object is not an instance of the class or interface declaring the underlying field (or a subclass or implementor thereof), or if an unwrapping conversion fails.
java.lang.NullPointerException - if the specified object is null and the field is an instance field.

setByte

void setByte(JClassInstance object,
             byte b)
             throws java.lang.IllegalArgumentException,
                    java.lang.IllegalAccessException
Sets the value of a field as a byte on the specified object. This method is equivalent to set(object, bObj), where bObj is a Byte object and bObj.byteValue() == b.

Parameters:
object - the object whose field should be modified
b - the new value for the field of obj being modified
Throws:
java.lang.IllegalAccessException - if the underlying field is inaccessible.
java.lang.IllegalArgumentException - if the specified object is not an instance of the class or interface declaring the underlying field (or a subclass or implementor thereof), or if an unwrapping conversion fails.
java.lang.NullPointerException - if the specified object is null and the field is an instance field.

setChar

void setChar(JClassInstance object,
             char c)
             throws java.lang.IllegalArgumentException,
                    java.lang.IllegalAccessException
Sets the value of a field as a char on the specified object. This method is equivalent to set(object, cObj), where cObj is a Char object and cObj.charValue() == c.

Parameters:
object - the object whose field should be modified
c - the new value for the field of obj being modified
Throws:
java.lang.IllegalAccessException - if the underlying field is inaccessible.
java.lang.IllegalArgumentException - if the specified object is not an instance of the class or interface declaring the underlying field (or a subclass or implementor thereof), or if an unwrapping conversion fails.
java.lang.NullPointerException - if the specified object is null and the field is an instance field.

setShort

void setShort(JClassInstance object,
              short s)
              throws java.lang.IllegalArgumentException,
                     java.lang.IllegalAccessException
Sets the value of a field as a short on the specified object. This method is equivalent to set(object, sObj), where sObj is a Short object and sObj.shortValue() == s.

Parameters:
object - the object whose field should be modified
s - the new value for the field of obj being modified
Throws:
java.lang.IllegalAccessException - if the underlying field is inaccessible.
java.lang.IllegalArgumentException - if the specified object is not an instance of the class or interface declaring the underlying field (or a subclass or implementor thereof), or if an unwrapping conversion fails.
java.lang.NullPointerException - if the specified object is null and the field is an instance field.

setInt

void setInt(JClassInstance object,
            int i)
            throws java.lang.IllegalArgumentException,
                   java.lang.IllegalAccessException
Sets the value of a field as a int on the specified object. This method is equivalent to set(object, iObj), where iObj is a Int object and iObj.intValue() == i.

Parameters:
object - the object whose field should be modified
i - the new value for the field of obj being modified
Throws:
java.lang.IllegalAccessException - if the underlying field is inaccessible.
java.lang.IllegalArgumentException - if the specified object is not an instance of the class or interface declaring the underlying field (or a subclass or implementor thereof), or if an unwrapping conversion fails.
java.lang.NullPointerException - if the specified object is null and the field is an instance field.

setLong

void setLong(JClassInstance object,
             long l)
             throws java.lang.IllegalArgumentException,
                    java.lang.IllegalAccessException
Sets the value of a field as a long on the specified object. This method is equivalent to set(object, lObj), where lObj is a Long object and lObj.longValue() == l.

Parameters:
object - the object whose field should be modified
l - the new value for the field of obj being modified
Throws:
java.lang.IllegalAccessException - if the underlying field is inaccessible.
java.lang.IllegalArgumentException - if the specified object is not an instance of the class or longerface declaring the underlying field (or a subclass or implementor thereof), or if an unwrapping conversion fails.
java.lang.NullPointerException - if the specified object is null and the field is an instance field.

setFloat

void setFloat(JClassInstance object,
              float f)
              throws java.lang.IllegalArgumentException,
                     java.lang.IllegalAccessException
Sets the value of a field as a float on the specified object. This method is equivalent to set(object, fObj), where fObj is a Float object and fObj.floatValue() == f.

Parameters:
object - the object whose field should be modified
f - the new value for the field of obj being modified
Throws:
java.lang.IllegalAccessException - if the underlying field is inaccessible.
java.lang.IllegalArgumentException - if the specified object is not an instance of the class or floaterface declaring the underlying field (or a subclass or implementor thereof), or if an unwrapping conversion fails.
java.lang.NullPointerException - if the specified object is null and the field is an instance field.

setDouble

void setDouble(JClassInstance object,
               double d)
               throws java.lang.IllegalArgumentException,
                      java.lang.IllegalAccessException
Sets the value of a field as a double on the specified object. This method is equivalent to set(object, dObj), where dObj is a Double object and dObj.doubleValue() == d.

Parameters:
object - the object whose field should be modified
d - the new value for the field of obj being modified
Throws:
java.lang.IllegalAccessException - if the underlying field is inaccessible.
java.lang.IllegalArgumentException - if the specified object is not an instance of the class or doubleerface declaring the underlying field (or a subclass or implementor thereof), or if an unwrapping conversion fails.
java.lang.NullPointerException - if the specified object is null and the field is an instance field.

getNativeField

java.lang.reflect.Field getNativeField()
Returns the java.lang.reflect.Field object equivalent to this JField object.

Returns:
the java.lang.reflect.Field object equivalent to this JField object
See Also:
Field