Build 1.0_r1(from source)

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 represents object fields that are saved to the stream, by serialization. Classes can define the collection of fields to be dumped, which can differ from the actual object's declared fields.

See Also:
ObjectOutputStream.writeFields(), ObjectInputStream.readFields()

Field Summary
(package private)  int offset
           
 
Constructor Summary
ObjectStreamField(String name, Class<?> cl)
          Constructs an ObjectStreamField with the given name and the given type
ObjectStreamField(String name, Class<?> cl, boolean unshared)
          Constructs an ObjectStreamField with the given name and the given type
ObjectStreamField(String signature, String name)
          Constructs an ObjectStreamField with the given name and the given type.
 
Method Summary
 int compareTo(Object o)
          Comparing the receiver to the parameter, according to the Comparable interface.
 boolean equals(Object arg0)
          Compares the argument to the receiver, and returns true if they represent the same object using a class specific comparison.
 String getName()
          Return the name of the field the receiver represents
 int getOffset()
          Return the offset of this field in the object
 Class<?> getType()
          Return the type of the field the receiver represents
 char getTypeCode()
          Return the type code that corresponds to the class the receiver represents
(package private)  Class<?> getTypeInternal()
          Return the type of the field the receiver represents, this is an internal method
 String getTypeString()
          Return the type signature used by the VM to represent the type for this field.
 int hashCode()
          Returns an integer hash code for the receiver.
 boolean isPrimitive()
          Return a boolean indicating whether the class of this field is a primitive type or not
 boolean isUnshared()
          Returns whether this serialized field is unshared.
(package private)  void resolve(ClassLoader loader)
           
protected  void setOffset(int newValue)
          Set the offset this field represents in the object
(package private)  void setUnshared(boolean unshared)
           
(package private) static void sortFields(ObjectStreamField[] fields)
          Sorts the fields for dumping.
 String toString()
          Returns a string containing a concise, human-readable description of the receiver.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

offset

int offset
Constructor Detail

ObjectStreamField

public ObjectStreamField(String name,
                         Class<?> cl)
Constructs an ObjectStreamField with the given name and the given type

Parameters:
name - a String, the name of the field
cl - A Class object representing the type of the field

ObjectStreamField

public ObjectStreamField(String name,
                         Class<?> cl,
                         boolean unshared)
Constructs an ObjectStreamField with the given name and the given type

Parameters:
name - a String, the name of the field
cl - A Class object representing the type of the field
unshared - write and read the field unshared

ObjectStreamField

ObjectStreamField(String signature,
                  String name)
Constructs an ObjectStreamField with the given name and the given type. The type may be null.

Parameters:
signature - A String representing the type of the field
name - a String, the name of the field, or null
Method Detail

compareTo

public int compareTo(Object o)
Comparing the receiver to the parameter, according to the Comparable interface.

Specified by:
compareTo in interface Comparable<Object>
Parameters:
o - The object to compare against
Returns:
-1 if the receiver is "smaller" than the parameter. 0 if the receiver is "equal" to the parameter. 1 if the receiver is "greater" than the parameter.

equals

public boolean equals(Object arg0)
Description copied from class: Object
Compares the argument to the receiver, and returns true if they represent the same object using a class specific comparison. The implementation in Object returns true only if the argument is the exact same object as the receiver (==).

Overrides:
equals in class Object
Parameters:
arg0 - Object the object to compare with this object.
Returns:
boolean true if the object is the same as this object false if it is different from this object.
See Also:
Object.hashCode()

hashCode

public int hashCode()
Description copied from class: Object
Returns an integer hash code for the receiver. Any two objects which answer true when passed to .equals must answer the same value for this method.

Overrides:
hashCode in class Object
Returns:
int the receiver's hash.
See Also:
Object.equals(java.lang.Object)

getName

public String getName()
Return the name of the field the receiver represents

Returns:
a String, the name of the field

getOffset

public int getOffset()
Return the offset of this field in the object

Returns:
an int, the offset

getTypeInternal

Class<?> getTypeInternal()
Return the type of the field the receiver represents, this is an internal method

Returns:
A Class object representing the type of the field

getType

public Class<?> getType()
Return the type of the field the receiver represents

Returns:
A Class object representing the type of the field

getTypeCode

public char getTypeCode()
Return the type code that corresponds to the class the receiver represents

Returns:
A char, the typecode of the class

getTypeString

public String getTypeString()
Return the type signature used by the VM to represent the type for this field.

Returns:
A String, the signature for the class of this field.

isPrimitive

public boolean isPrimitive()
Return a boolean indicating whether the class of this field is a primitive type or not

Returns:
true if the type of this field is a primitive type false if the type of this field is a regular class.

setOffset

protected void setOffset(int newValue)
Set the offset this field represents in the object

Parameters:
newValue - an int, the offset

toString

public String toString()
Returns a string containing a concise, human-readable description of the receiver.

Overrides:
toString in class Object
Returns:
a printable representation for the receiver.

sortFields

static void sortFields(ObjectStreamField[] fields)
Sorts the fields for dumping. Primitive types come first, then regular types.

Parameters:
fields - ObjectStreamField[] fields to be sorted

resolve

void resolve(ClassLoader loader)

isUnshared

public boolean isUnshared()
Returns whether this serialized field is unshared.

Returns:
true if the field is unshared, false otherwise.

setUnshared

void setUnshared(boolean unshared)

Build 1.0_r1(from source)

Please submit a feedback, bug or feature