Class SerializableField

java.lang.Object
org.jboss.marshalling.reflect.SerializableField

public final class SerializableField extends Object
Reflection information about a field on a serializable class.
  • Constructor Summary

    Constructors
    Constructor
    Description
    SerializableField(Class<?> type, String name, boolean unshared)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    getBoolean(Object instance)
    Get the boolean value of this field on the given object instance.
    byte
    getByte(Object instance)
    Get the byte value of this field on the given object instance.
    char
    getChar(Object instance)
    Get the char value of this field on the given object instance.
    double
    getDouble(Object instance)
    Get the double value of this field on the given object instance.
    Deprecated.
    As of Java 9, accessible fields are generally disallowed; use the #setXXX(Object,value) methods instead.
    float
    getFloat(Object instance)
    Get the float value of this field on the given object instance.
    int
    getInt(Object instance)
    Get the integer value of this field on the given object instance.
    Get the kind of field.
    long
    getLong(Object instance)
    Get the long value of this field on the given object instance.
    Get the name of the field.
    getObject(Object instance)
    Get the object value of this field on the given object instance.
    int
    Getter for the record component index.
    Getter for the record component value.
    short
    getShort(Object instance)
    Get the short value of this field on the given object instance.
    Get the field type.
    boolean
    Determine if this object may be used to get or set an object field value.
    boolean
    Determine whether this field is marked as "unshared".
    void
    readFrom(Object instance, ObjectInput input)
    Read the field value from the stream.
    void
    setBoolean(Object instance, boolean value)
    Set the boolean value of this field on the given object instance.
    void
    setByte(Object instance, byte value)
    Set the byte value of this field on the given object instance.
    void
    setChar(Object instance, char value)
    Set the char value of this field on the given object instance.
    void
    setDouble(Object instance, double value)
    Set the double value of this field on the given object instance.
    void
    setFloat(Object instance, float value)
    Set the float value of this field on the given object instance.
    void
    setInt(Object instance, int value)
    Set the integer value of this field on the given object instance.
    void
    setLong(Object instance, long value)
    Set the long value of this field on the given object instance.
    void
    setObject(Object instance, Object value)
    Set the object value of this field on the given object instance.
    void
    setShort(Object instance, short value)
    Set the short value of this field on the given object instance.
    void
    writeTo(Object instance, ObjectOutput output)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • SerializableField

      public SerializableField(Class<?> type, String name, boolean unshared)
  • Method Details

    • getField

      @Deprecated public Field getField()
      Deprecated.
      As of Java 9, accessible fields are generally disallowed; use the #setXXX(Object,value) methods instead.
      Get the reflection Field for this serializable field. The resultant field will be accessible.
      Returns:
      the reflection field
    • isAccessible

      public boolean isAccessible()
      Determine if this object may be used to get or set an object field value.
      Returns:
      true if this object may be used to get or set an object field value, false otherwise
    • getName

      public String getName()
      Get the name of the field.
      Returns:
      the name
    • isUnshared

      public boolean isUnshared()
      Determine whether this field is marked as "unshared".
      Returns:
      true if the field is unshared
    • getKind

      public Kind getKind()
      Get the kind of field.
      Returns:
      the kind
    • getType

      public Class<?> getType() throws ClassNotFoundException
      Get the field type.
      Returns:
      the field type
      Throws:
      ClassNotFoundException
    • setBoolean

      public void setBoolean(Object instance, boolean value) throws ClassCastException, IllegalArgumentException
      Set the boolean value of this field on the given object instance.
      Parameters:
      instance - the object instance (must not be null, must be of the correct type)
      value - the value to set
      Throws:
      ClassCastException - if instance or the field is not of the correct type
      IllegalArgumentException - if this instance has no reflection field set on it
    • setChar

      public void setChar(Object instance, char value) throws ClassCastException, IllegalArgumentException
      Set the char value of this field on the given object instance.
      Parameters:
      instance - the object instance (must not be null, must be of the correct type)
      value - the value to set
      Throws:
      ClassCastException - if instance or the field is not of the correct type
      IllegalArgumentException - if this instance has no reflection field set on it
    • setByte

      public void setByte(Object instance, byte value) throws ClassCastException, IllegalArgumentException
      Set the byte value of this field on the given object instance.
      Parameters:
      instance - the object instance (must not be null, must be of the correct type)
      value - the value to set
      Throws:
      ClassCastException - if instance is not of the correct type
      IllegalArgumentException - if this instance has no reflection field set on it
    • setShort

      public void setShort(Object instance, short value) throws ClassCastException, IllegalArgumentException
      Set the short value of this field on the given object instance.
      Parameters:
      instance - the object instance (must not be null, must be of the correct type)
      value - the value to set
      Throws:
      ClassCastException - if instance or the field is not of the correct type
      IllegalArgumentException - if this instance has no reflection field set on it
    • setInt

      public void setInt(Object instance, int value) throws ClassCastException, IllegalArgumentException
      Set the integer value of this field on the given object instance.
      Parameters:
      instance - the object instance (must not be null, must be of the correct type)
      value - the value to set
      Throws:
      ClassCastException - if instance or the field is not of the correct type
      IllegalArgumentException - if this instance has no reflection field set on it
    • setLong

      public void setLong(Object instance, long value) throws ClassCastException, IllegalArgumentException
      Set the long value of this field on the given object instance.
      Parameters:
      instance - the object instance (must not be null, must be of the correct type)
      value - the value to set
      Throws:
      ClassCastException - if instance or the field is not of the correct type
      IllegalArgumentException - if this instance has no reflection field set on it
    • setFloat

      public void setFloat(Object instance, float value) throws ClassCastException, IllegalArgumentException
      Set the float value of this field on the given object instance.
      Parameters:
      instance - the object instance (must not be null, must be of the correct type)
      value - the value to set
      Throws:
      ClassCastException - if instance or the field is not of the correct type
      IllegalArgumentException - if this instance has no reflection field set on it
    • setDouble

      public void setDouble(Object instance, double value) throws ClassCastException, IllegalArgumentException
      Set the double value of this field on the given object instance.
      Parameters:
      instance - the object instance (must not be null, must be of the correct type)
      value - the value to set
      Throws:
      ClassCastException - if instance or the field is not of the correct type
      IllegalArgumentException - if this instance has no reflection field set on it
    • setObject

      public void setObject(Object instance, Object value) throws ClassCastException, IllegalArgumentException
      Set the object value of this field on the given object instance.
      Parameters:
      instance - the object instance (must not be null, must be of the correct type)
      value - the value to set
      Throws:
      ClassCastException - if instance or the field is not of the correct type
      IllegalArgumentException - if this instance has no reflection field set on it
    • getBoolean

      public boolean getBoolean(Object instance) throws ClassCastException, IllegalArgumentException
      Get the boolean value of this field on the given object instance.
      Parameters:
      instance - the object instance (must not be null, must be of the correct type)
      Returns:
      the value of the field
      Throws:
      ClassCastException - if the field is not of the correct type
      IllegalArgumentException - if this instance has no reflection field set on it
    • getChar

      public char getChar(Object instance) throws ClassCastException, IllegalArgumentException
      Get the char value of this field on the given object instance.
      Parameters:
      instance - the object instance (must not be null, must be of the correct type)
      Returns:
      the value of the field
      Throws:
      ClassCastException - if the field is not of the correct type
      IllegalArgumentException - if this instance has no reflection field set on it
    • getByte

      public byte getByte(Object instance) throws ClassCastException, IllegalArgumentException
      Get the byte value of this field on the given object instance.
      Parameters:
      instance - the object instance (must not be null, must be of the correct type)
      Returns:
      the value of the field
      Throws:
      ClassCastException - if the field is not of the correct type
      IllegalArgumentException - if this instance has no reflection field set on it
    • getShort

      public short getShort(Object instance) throws ClassCastException, IllegalArgumentException
      Get the short value of this field on the given object instance.
      Parameters:
      instance - the object instance (must not be null, must be of the correct type)
      Returns:
      the value of the field
      Throws:
      ClassCastException - if the field is not of the correct type
      IllegalArgumentException - if this instance has no reflection field set on it
    • getInt

      public int getInt(Object instance) throws ClassCastException, IllegalArgumentException
      Get the integer value of this field on the given object instance.
      Parameters:
      instance - the object instance (must not be null, must be of the correct type)
      Returns:
      the value of the field
      Throws:
      ClassCastException - if the field is not of the correct type
      IllegalArgumentException - if this instance has no reflection field set on it
    • getLong

      public long getLong(Object instance) throws ClassCastException, IllegalArgumentException
      Get the long value of this field on the given object instance.
      Parameters:
      instance - the object instance (must not be null, must be of the correct type)
      Returns:
      the value of the field
      Throws:
      ClassCastException - if the field is not of the correct type
      IllegalArgumentException - if this instance has no reflection field set on it
    • getFloat

      public float getFloat(Object instance) throws ClassCastException, IllegalArgumentException
      Get the float value of this field on the given object instance.
      Parameters:
      instance - the object instance (must not be null, must be of the correct type)
      Returns:
      the value of the field
      Throws:
      ClassCastException - if the field is not of the correct type
      IllegalArgumentException - if this instance has no reflection field set on it
    • getDouble

      public double getDouble(Object instance) throws ClassCastException, IllegalArgumentException
      Get the double value of this field on the given object instance.
      Parameters:
      instance - the object instance (must not be null, must be of the correct type)
      Returns:
      the value of the field
      Throws:
      ClassCastException - if the field is not of the correct type
      IllegalArgumentException - if this instance has no reflection field set on it
    • getObject

      public Object getObject(Object instance) throws ClassCastException, IllegalArgumentException
      Get the object value of this field on the given object instance.
      Parameters:
      instance - the object instance (must not be null, must be of the correct type)
      Returns:
      the value of the field
      Throws:
      ClassCastException - if the field is not of the correct type
      IllegalArgumentException - if this instance has no reflection field set on it
    • readFrom

      public void readFrom(Object instance, ObjectInput input) throws IOException, ClassNotFoundException
      Read the field value from the stream.
      Parameters:
      instance - the instance
      input - the source stream
      Throws:
      IOException - if an I/O error occurs
      ClassNotFoundException - if a class could not be loaded
    • writeTo

      public void writeTo(Object instance, ObjectOutput output) throws IOException
      Throws:
      IOException
    • getRecordComponentValue

      public Object getRecordComponentValue(Object obj)
      Getter for the record component value.
      Parameters:
      obj - The object to obtain the record component value
      Returns:
      The record component value for this obj
    • getRecordComponentIndex

      public int getRecordComponentIndex()
      Getter for the record component index.
      Returns:
      The record component index or -1