home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgLangD.iso / VCAFE.3.0A / Main.bin / Serializable.java < prev    next >
Text File  |  1998-09-22  |  4KB  |  87 lines

  1. /*
  2.  * @(#)Serializable.java    1.7 98/07/01
  3.  *
  4.  * Copyright 1995-1998 by Sun Microsystems, Inc.,
  5.  * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
  6.  * All rights reserved.
  7.  * 
  8.  * This software is the confidential and proprietary information
  9.  * of Sun Microsystems, Inc. ("Confidential Information").  You
  10.  * shall not disclose such Confidential Information and shall use
  11.  * it only in accordance with the terms of the license agreement
  12.  * you entered into with Sun.
  13.  */
  14.  
  15. package java.io;
  16.  
  17. /**
  18.  * Serializability of a class is enabled by the class implementing the
  19.  * java.io.Serializable interface. Classes that do not implement this
  20.  * interface will not have any of their state serialized or
  21.  * deserialized.  All subtypes of a serializable class are themselves
  22.  * serializable.  The serialization interface has no methods or fields
  23.  * and serves only to identify the semantics of being serializable. <p>
  24.  * 
  25.  * To allow subtypes of non-serializable classes to be serialized, the
  26.  * subtype may assume responsibility for saving and restoring the
  27.  * state of the supertype's public, protected, and (if accessible)
  28.  * package fields.  The subtype may assume this responsibility only if
  29.  * the class it extends has an accessible no-arg constructor to
  30.  * initialize the class's state.  It is an error to declare a class
  31.  * Serializable in this case.  The error will be detected at runtime. <p>
  32.  * 
  33.  * During deserialization, the fields of non-serializable classes will
  34.  * be initialized using the public or protected no-arg constructor of
  35.  * the class.  A no-arg constructor must be accessible to the subclass
  36.  * that is serializable.  The fields of serializable subclasses will
  37.  * be restored from the stream. <p>
  38.  *
  39.  * When traversing a graph, an object may be encountered that does not
  40.  * support the Serializable interface. In this case the
  41.  * NotSerializableException will be thrown and will identify the class
  42.  * of the non-serializable object. <p>
  43.  *
  44.  * Classes that require special handling during the serialization and deserialization
  45.  * process must implement special methods with these exact signatures: <p>
  46.  *
  47.  * <PRE>
  48.  * private void writeObject(java.io.ObjectOutputStream out)
  49.  *     throws IOException
  50.  * private void readObject(java.io.ObjectInputStream in)
  51.  *     throws IOException, ClassNotFoundException; 
  52.  * </PRE><p>
  53.  
  54.  * The writeObject method is responsible for writing the state of the
  55.  * object for its particular class so that the corresponding
  56.  * readObject method can restore it.  The default mechanism for saving
  57.  * the Object's fields can be invoked by calling
  58.  * out.defaultWriteObject. The method does not need to concern
  59.  * itself with the state belonging to its superclasses or subclasses.
  60.  * State is saved by writing the individual fields to the
  61.  * ObjectOutputStream using the writeObject method or by using the
  62.  * methods for primitive data types supported by DataOutput. <p>
  63.  
  64.  * The readObject method is responsible for reading from the stream and restoring
  65.  * the classes fields. It may call in.defaultReadObject to invoke
  66.  * the default mechanism for restoring the object's non-static and non-transient
  67.  * fields.  The defaultReadObject method uses information in the stream to
  68.  * assign the fields of the object saved in the stream with the correspondingly
  69.  * named fields in the current object.  This handles the case when the class
  70.  * has evolved to add new fields. The method does not need to concern
  71.  * itself with the state belonging to its superclasses or subclasses.
  72.  * State is saved by writing the individual fields to the
  73.  * ObjectOutputStream using the writeObject method or by using the
  74.  * methods for primitive data types supported by DataOutput. <p>
  75.  *
  76.  * @author  unascribed
  77.  * @version 1.7, 07/01/98
  78.  * @see java.io.ObjectOutputStream
  79.  * @see java.io.ObjectInputStream
  80.  * @see java.io.ObjectOutput
  81.  * @see java.io.ObjectInput
  82.  * @see java.io.Externalizable
  83.  * @since   JDK1.1
  84.  */
  85. public interface Serializable {
  86. }
  87.