source: trunk/gcc/libjava/java/io/Externalizable.java

Last change on this file was 1392, checked in by bird, 21 years ago

This commit was generated by cvs2svn to compensate for changes in r1391,
which included commits to RCS files with non-trunk default branches.

  • Property cvs2svn:cvs-rev set to 1.1.1.2
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 4.8 KB
Line 
1/* Externalizable.java -- Interface for saving and restoring object data
2 Copyright (C) 1998 Free Software Foundation, Inc.
3
4This file is part of GNU Classpath.
5
6GNU Classpath is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2, or (at your option)
9any later version.
10
11GNU Classpath is distributed in the hope that it will be useful, but
12WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GNU Classpath; see the file COPYING. If not, write to the
18Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
1902111-1307 USA.
20
21Linking this library statically or dynamically with other modules is
22making a combined work based on this library. Thus, the terms and
23conditions of the GNU General Public License cover the whole
24combination.
25
26As a special exception, the copyright holders of this library give you
27permission to link this library with independent modules to produce an
28executable, regardless of the license terms of these independent
29modules, and to copy and distribute the resulting executable under
30terms of your choice, provided that you also meet, for each linked
31independent module, the terms and conditions of the license of that
32module. An independent module is a module which is not derived from
33or based on this library. If you modify this library, you may extend
34this exception to your version of the library, but you are not
35obligated to do so. If you do not wish to do so, delete this
36exception statement from your version. */
37
38
39package java.io;
40
41/**
42 * This interface provides a way that classes can completely control how
43 * the data of their object instances are written and read to and from
44 * streams. It has two methods which are used to write the data to a stream
45 * and to read the data from a stream. The read method must read the data
46 * in exactly the way it was written by the write method.
47 * <p>
48 * Note that classes which implement this interface must take into account
49 * that all superclass data must also be written to the stream as well.
50 * The class implementing this interface must figure out how to make that
51 * happen.
52 * <p>
53 * This interface can be used to provide object persistence. When an
54 * object is to be stored externally, the <code>writeExternal</code> method is
55 * called to save state. When the object is restored, an instance is
56 * created using the default no-argument constructor and the
57 * <code>readExternal</code> method is used to restore the state.
58 *
59 * @version 0.0
60 *
61 * @author Aaron M. Renn (arenn@urbanophile.com)
62 */
63public interface Externalizable extends Serializable
64{
65 static final long serialVersionUID = -282491828744381764L;
66
67/**
68 * This method restores an object's state by reading in the instance data
69 * for the object from the passed in stream. Note that this stream is not
70 * a subclass of <code>InputStream</code>, but rather is a class that implements
71 * the <code>ObjectInput</code> interface. That interface provides a mechanism for
72 * reading in Java data types from a stream.
73 * <p>
74 * Note that this method must be compatible with <code>writeExternal</code>.
75 * It must read back the exact same types that were written by that
76 * method in the exact order they were written.
77 * <p>
78 * If this method needs to read back an object instance, then the class
79 * for that object must be found and loaded. If that operation fails,
80 * then this method throws a <code>ClassNotFoundException</code>
81 *
82 * @param in An <code>ObjectInput</code> instance for reading in the object state
83 *
84 * @exception ClassNotFoundException If the class of an object being restored cannot be found
85 * @exception IOException If any other error occurs
86 */
87public abstract void
88readExternal(ObjectInput in) throws ClassNotFoundException, IOException;
89
90/*************************************************************************/
91
92/**
93 * This method is responsible for writing the instance data of an object
94 * to the passed in stream. Note that this stream is not a subclass of
95 * <code>OutputStream</code>, but rather is a class that implements the
96 * <code>ObjectOutput</code> interface. That interface provides a number of methods
97 * for writing Java data values to a stream.
98 * <p>
99 * Not that the implementation of this method must be coordinated with
100 * the implementation of <code>readExternal</code>.
101 *
102 * @param out An <code>ObjectOutput</code> instance for writing the object state
103 *
104 * @exception IOException If an error occurs
105 */
106public abstract void
107writeExternal(ObjectOutput out) throws IOException;
108
109} // interface Externalizable
110
Note: See TracBrowser for help on using the repository browser.