fr.umlv.corosol.component.impl
Class DefaultJField

java.lang.Object
  extended by fr.umlv.corosol.component.impl.DefaultJField
All Implemented Interfaces:
JField, JObject

public class DefaultJField
extends java.lang.Object
implements JField

This is the default implementation of the JField interface.

Author:
Christophe Deleray

Constructor Summary
DefaultJField(JClass declaringClass, JClassMember fieldInfo)
          Creates a new DefaultJField object initialized with the specified class file item that containing the field datas and with the specified declaring class.
 
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.
 java.lang.String toString()
          Returns a string describing this DefaultJField.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DefaultJField

public DefaultJField(JClass declaringClass,
                     JClassMember fieldInfo)
Creates a new DefaultJField object initialized with the specified class file item that containing the field datas and with the specified declaring class.

Parameters:
declaringClass - the class declaring the field
fieldInfo - the class file item containing the field datas
Method Detail

getNativeField

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

Specified by:
getNativeField in interface JField
Returns:
the java.lang.reflect.Field object equivalent to this JField object
See Also:
Field

getDeclaringClass

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

Specified by:
getDeclaringClass in interface JField
Returns:
the class declaring this field

getName

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

Specified by:
getName in interface JField

getModifiers

public 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.

Specified by:
getModifiers in interface JField
See Also:
Modifier

getDescriptor

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

Specified by:
getDescriptor in interface JField

getType

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

Specified by:
getType in interface JField
Returns:
a JClass object identifying the declared type of the field represented by this object

isStatic

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

Specified by:
isStatic in interface JField
Returns:
true if and only if this field is static; false otherwise.

get

public 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.

Specified by:
get in interface JField
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

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

Specified by:
getBoolean in interface JField
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

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

Specified by:
getByte in interface JField
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

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

Specified by:
getChar in interface JField
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

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

Specified by:
getShort in interface JField
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

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

Specified by:
getInt in interface JField
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

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

Specified by:
getLong in interface JField
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

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

Specified by:
getFloat in interface JField
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

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

Specified by:
getDouble in interface JField
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

public 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.

Specified by:
set in interface JField
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

public 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.

Specified by:
setBoolean in interface JField
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

public 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.

Specified by:
setByte in interface JField
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

public 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.

Specified by:
setChar in interface JField
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

public 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.

Specified by:
setShort in interface JField
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

public 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.

Specified by:
setInt in interface JField
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

public 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.

Specified by:
setLong in interface JField
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

public 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.

Specified by:
setFloat in interface JField
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

public 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.

Specified by:
setDouble in interface JField
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.

toString

public java.lang.String toString()
Returns a string describing this DefaultJField.

Overrides:
toString in class java.lang.Object