home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 November / Chip_1998-11_cd.bin / tema / Cafe / main.bin / Serializable.java < prev    next >
Text File  |  1997-05-20  |  4KB  |  94 lines

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