Team LiB
Previous Section Next Section

Java 1.1serializable

This class represents a class that is being serialized. An ObjectStreamClass object contains the name of a class, its unique version identifier, and the name and type of the fields that constitute the serialization format for the class. getSerialVersionUID( ) returns a unique version identifier for the class. It returns either the value of the private serialVersionUID field of the class or a computed value that is based upon the public API of the class. In Java 1.2 and later, getFields( ) returns an array of ObjectStreamField objects that represent the names and types of the fields of the class to be serialized. getField( ) returns a single ObjectStreamField object that represents a single named field. By default, these methods use all the fields of a class except those that are static or transient. However, this default set of fields can be overridden by declaring a private serialPersistentFields field in the class. The value of this field should be the desired array of ObjectStreamField objects.

ObjectStreamClass class does not have a constructor; you should use the static lookup( ) method to obtain an ObjectStreamClass object for a given Class object. The forClass( ) instance method performs the opposite operation; it returns the Class object that corresponds to a given ObjectStreamClass. Most applications never need to use this class.

Figure 9-39.

public class ObjectStreamClass implements Serializable {
// No Constructor
// Public Constants
1.2  public static final ObjectStreamField[ ] NO_FIELDS;  
// Public Class Methods
     public static ObjectStreamClass lookup(Class<?> cl);  
// Public Instance Methods
     public Class<?> forClass( );  
1.2  public ObjectStreamField getField(String name);  
1.2  public ObjectStreamField[ ] getFields( );  
     public String getName( );  
     public long getSerialVersionUID( );  
// Public Methods Overriding Object
     public String toString( );  

Passed To

ObjectInputStream.resolveClass( ), ObjectOutputStream.writeClassDescriptor( )

Returned By

ObjectInputStream.readClassDescriptor( ), ObjectInputStream.GetField.getObjectStreamClass( )

    Team LiB
    Previous Section Next Section