java.io

Class ObjectStreamField

Implemented Interfaces:
Comparable<T>

public class ObjectStreamField
extends Object
implements Comparable<T>

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, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Details

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 Details

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.

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.

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.
Overrides:
toString in interface Object
Returns:
the string.

ObjectStreamField.java -- Class used to store name and class of fields Copyright (C) 1998, 1999, 2003, 2004, 2005 Free Software Foundation, Inc. This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.