java.io
Class ObjectStreamField

java.lang.Object
  extended by java.io.ObjectStreamField
All Implemented Interfaces:
Comparable<Object>

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
 int compareTo(Object obj)
          Compares this object to the given object.
 String getName()
          This method returns the name of the field represented by the ObjectStreamField instance.
 int getOffset()
          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.
 char getTypeCode()
          This method returns the char encoded type of the field which is represented by this instance of ObjectStreamField.
 String getTypeString()
          This method returns a more explicit type name than getTypeCode() in the case the type is a real class (and not a primitive).
 boolean isPrimitive()
          This method returns true if the type of the field represented by this instance is a primitive.
 boolean isUnshared()
          This method returns whether the field represented by this object is unshared or not.
protected  void setOffset(int off)
          This method sets the current offset of the field.
 String toString()
          Returns a string representing this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

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

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.

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

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:
setOffset(int)

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()

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.

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.

compareTo

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

Specified by:
compareTo in interface Comparable<Object>
Parameters:
obj - the object to compare to.
Returns:
-1, 0 or 1.

toString

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

Overrides:
toString in class Object
Returns:
the string.
See Also:
Object.getClass(), Object.hashCode(), Class.getName(), Integer.toHexString(int)