Package org.jboss.marshalling.reflect
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
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description booleangetBoolean(Object instance)Get the boolean value of this field on the given object instance.bytegetByte(Object instance)Get the byte value of this field on the given object instance.chargetChar(Object instance)Get the char value of this field on the given object instance.doublegetDouble(Object instance)Get the double value of this field on the given object instance.FieldgetField()Deprecated.As of Java 9, accessible fields are generally disallowed; use the#setXXX(Object,value)methods instead.floatgetFloat(Object instance)Get the float value of this field on the given object instance.intgetInt(Object instance)Get the integer value of this field on the given object instance.KindgetKind()Get the kind of field.longgetLong(Object instance)Get the long value of this field on the given object instance.StringgetName()Get the name of the field.ObjectgetObject(Object instance)Get the object value of this field on the given object instance.shortgetShort(Object instance)Get the short value of this field on the given object instance.Class<?>getType()Get the field type.booleanisAccessible()Determine if this object may be used to get or set an object field value.booleanisUnshared()Determine whether this field is marked as "unshared".voidreadFrom(Object instance, ObjectInput input)Read the field value from the stream.voidsetBoolean(Object instance, boolean value)Set the boolean value of this field on the given object instance.voidsetByte(Object instance, byte value)Set the byte value of this field on the given object instance.voidsetChar(Object instance, char value)Set the char value of this field on the given object instance.voidsetDouble(Object instance, double value)Set the double value of this field on the given object instance.voidsetFloat(Object instance, float value)Set the float value of this field on the given object instance.voidsetInt(Object instance, int value)Set the integer value of this field on the given object instance.voidsetLong(Object instance, long value)Set the long value of this field on the given object instance.voidsetObject(Object instance, Object value)Set the object value of this field on the given object instance.voidsetShort(Object instance, short value)Set the short value of this field on the given object instance.voidwriteTo(Object instance, ObjectOutput output)
-
-
-
Method Detail
-
getField
@Deprecated public Field getField()
Deprecated.As of Java 9, accessible fields are generally disallowed; use the#setXXX(Object,value)methods instead.Get the reflectionFieldfor 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:
trueif this object may be used to get or set an object field value,falseotherwise
-
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:
trueif 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 benull, must be of the correct type)value- the value to set- Throws:
ClassCastException- ifinstanceor the field is not of the correct typeIllegalArgumentException- 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 benull, must be of the correct type)value- the value to set- Throws:
ClassCastException- ifinstanceor the field is not of the correct typeIllegalArgumentException- 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 benull, must be of the correct type)value- the value to set- Throws:
ClassCastException- ifinstanceis not of the correct typeIllegalArgumentException- 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 benull, must be of the correct type)value- the value to set- Throws:
ClassCastException- ifinstanceor the field is not of the correct typeIllegalArgumentException- 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 benull, must be of the correct type)value- the value to set- Throws:
ClassCastException- ifinstanceor the field is not of the correct typeIllegalArgumentException- 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 benull, must be of the correct type)value- the value to set- Throws:
ClassCastException- ifinstanceor the field is not of the correct typeIllegalArgumentException- 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 benull, must be of the correct type)value- the value to set- Throws:
ClassCastException- ifinstanceor the field is not of the correct typeIllegalArgumentException- 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 benull, must be of the correct type)value- the value to set- Throws:
ClassCastException- ifinstanceor the field is not of the correct typeIllegalArgumentException- 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 benull, must be of the correct type)value- the value to set- Throws:
ClassCastException- ifinstanceor the field is not of the correct typeIllegalArgumentException- 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 benull, must be of the correct type)- Returns:
- the value of the field
- Throws:
ClassCastException- if the field is not of the correct typeIllegalArgumentException- 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 benull, must be of the correct type)- Returns:
- the value of the field
- Throws:
ClassCastException- if the field is not of the correct typeIllegalArgumentException- 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 benull, must be of the correct type)- Returns:
- the value of the field
- Throws:
ClassCastException- if the field is not of the correct typeIllegalArgumentException- 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 benull, must be of the correct type)- Returns:
- the value of the field
- Throws:
ClassCastException- if the field is not of the correct typeIllegalArgumentException- 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 benull, must be of the correct type)- Returns:
- the value of the field
- Throws:
ClassCastException- if the field is not of the correct typeIllegalArgumentException- 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 benull, must be of the correct type)- Returns:
- the value of the field
- Throws:
ClassCastException- if the field is not of the correct typeIllegalArgumentException- 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 benull, must be of the correct type)- Returns:
- the value of the field
- Throws:
ClassCastException- if the field is not of the correct typeIllegalArgumentException- 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 benull, must be of the correct type)- Returns:
- the value of the field
- Throws:
ClassCastException- if the field is not of the correct typeIllegalArgumentException- 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 benull, must be of the correct type)- Returns:
- the value of the field
- Throws:
ClassCastException- if the field is not of the correct typeIllegalArgumentException- 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 instanceinput- the source stream- Throws:
IOException- if an I/O error occursClassNotFoundException- if a class could not be loaded
-
writeTo
public void writeTo(Object instance, ObjectOutput output) throws IOException
- Throws:
IOException
-
-