java.io

Class ObjectStreamField

public class ObjectStreamField extends Object implements Comparable<Object>

This class intends to describe the field of a class for the serialization subsystem. Serializable fields in a serializable class can be explicitly exported using an array of ObjectStreamFields.
Constructor Summary
ObjectStreamField(String name, Class<?> type)
This constructor creates an ObjectStreamField instance which represents a field named name and is of the type type.
ObjectStreamField(String name, Class<?> type, boolean unshared)
This constructor creates an ObjectStreamField instance which represents a field named name and is of the type type.
Method Summary
intcompareTo(Object obj)
Compares this object to the given object.
StringgetName()
This method returns the name of the field represented by the ObjectStreamField instance.
intgetOffset()
This method returns the current offset of the field in the serialization stream relatively to the other fields.
Class<?>getType()
This method returns the class representing the type of the field which is represented by this instance of ObjectStreamField.
chargetTypeCode()
This method returns the char encoded type of the field which is represented by this instance of ObjectStreamField.
StringgetTypeString()
This method returns a more explicit type name than {@link #getTypeCode()} in the case the type is a real class (and not a primitive).
booleanisPrimitive()
This method returns true if the type of the field represented by this instance is a primitive.
booleanisUnshared()
This method returns whether the field represented by this object is unshared or not.
protected voidsetOffset(int off)
This method sets the current offset of the field.
StringtoString()
Returns a string representing this object.

Constructor Detail

ObjectStreamField

public ObjectStreamField(String name, Class<?> type)
This constructor creates an ObjectStreamField instance which represents a field named name and is of the type type.

Parameters: name Name of the field to export. type Type of the field in the concerned class.

ObjectStreamField

public ObjectStreamField(String name, Class<?> type, boolean unshared)
This constructor creates an ObjectStreamField instance which represents a field named name and is of the type type.

Parameters: name Name of the field to export. type Type of the field in the concerned class. unshared true if field will be unshared, false otherwise.

Method Detail

compareTo

public int compareTo(Object obj)
Compares this object to the given object.

Parameters: obj the object to compare to.

Returns: -1, 0 or 1.

getName

public String getName()
This method returns the name of the field represented by the ObjectStreamField instance.

Returns: A string containing the name of the field.

getOffset

public int getOffset()
This method returns the current offset of the field in the serialization stream relatively to the other fields. The offset is expressed in bytes.

Returns: The offset of the field in bytes.

See Also: ObjectStreamField

getType

public Class<?> getType()
This method returns the class representing the type of the field which is represented by this instance of ObjectStreamField.

Returns: A class representing the type of the field.

getTypeCode

public char getTypeCode()
This method returns the char encoded type of the field which is represented by this instance of ObjectStreamField.

Returns: A char representing the type of the field.

getTypeString

public String getTypeString()
This method returns a more explicit type name than {@link #getTypeCode()} in the case the type is a real class (and not a primitive).

Returns: The name of the type (class name) if it is not a primitive, in the other case null is returned.

isPrimitive

public boolean isPrimitive()
This method returns true if the type of the field represented by this instance is a primitive.

Returns: true if the type is a primitive, false in the other case.

isUnshared

public boolean isUnshared()
This method returns whether the field represented by this object is unshared or not.

Returns: Tells if this field is unshared or not.

setOffset

protected void setOffset(int off)
This method sets the current offset of the field.

Parameters: off The offset of the field in bytes.

See Also: getOffset

toString

public String toString()
Returns a string representing this object.

Returns: the string.