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

  1. /*
  2.  * @(#)Externalizable.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. import java.io.ObjectOutput;
  25. import java.io.ObjectInput;
  26.  
  27. /**
  28.  * Externalization allows a class to specify the methods to be used to
  29.  * write the object's contents to a stream and to read them back.  The
  30.  * Externalizable interface's writeExternal and readExternal methods
  31.  * are implemented by a class to
  32.  * give the class complete control over the format and contents of the
  33.  * stream for an object and its supertypes. These methods must explicitly
  34.  * coordinate with the supertype to save its state. <br>
  35.  *
  36.  * Object Serialization uses the Serializable and Externalizable
  37.  * interfaces.  Object persistence mechanisms may use them also.  Each
  38.  * object to be stored is tested for the Externalizable interface. If
  39.  * the object supports it, the writeExternal method is called. If the
  40.  * object does not support Externalizable and does implement
  41.  * Serializable the object should be saved using
  42.  * ObjectOutputStream. <br> When an Externalizable object is to be
  43.  * reconstructed, an instance is created using the public no-arg
  44.  * constructor and the readExternal method called.  Serializable
  45.  * objects are restored by reading them from an ObjectInputStream.
  46.  *
  47.  * @author  unascribed
  48.  * @version 1.6, 01/22/97
  49.  * @see java.io.ObjectOutputStream
  50.  * @see java.io.ObjectInputStream
  51.  * @see java.io.ObjectOutput
  52.  * @see java.io.ObjectInput
  53.  * @see java.io.Serializable
  54.  * @since   JDK1.1
  55.  */
  56. public interface Externalizable extends java.io.Serializable {
  57.     /**
  58.      * The object implements the writeExternal method to save its contents
  59.      * by calling the methods of DataOutput for its primitive values or
  60.      * calling the writeObject method of ObjectOutput for objects, strings
  61.      * and arrays.
  62.      * @exception IOException Includes any I/O exceptions that may occur
  63.      * @since     JDK1.1
  64.      */
  65.     void writeExternal(ObjectOutput out) throws IOException;
  66.  
  67.     /**
  68.      * The object implements the readExternal method to restore its
  69.      * contents by calling the methods of DataInput for primitive
  70.      * types and readObject for objects, strings and arrays.  The
  71.      * readExternal method must read the values in the same sequence
  72.      * and with the same types as were written by writeExternal.
  73.      * @exception ClassNotFoundException If the class for an object being
  74.      *              restored cannot be found.
  75.      * @since     JDK1.1
  76.      */
  77.     void readExternal(ObjectInput in) throws IOException, ClassNotFoundException;
  78. }
  79.