1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/rt/emul/compact/src/main/java/java/io/Externalizable.java Tue Feb 26 16:54:16 2013 +0100
1.3 @@ -0,0 +1,97 @@
1.4 +/*
1.5 + * Copyright (c) 1996, 2004, Oracle and/or its affiliates. All rights reserved.
1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1.7 + *
1.8 + * This code is free software; you can redistribute it and/or modify it
1.9 + * under the terms of the GNU General Public License version 2 only, as
1.10 + * published by the Free Software Foundation. Oracle designates this
1.11 + * particular file as subject to the "Classpath" exception as provided
1.12 + * by Oracle in the LICENSE file that accompanied this code.
1.13 + *
1.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
1.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
1.17 + * version 2 for more details (a copy is included in the LICENSE file that
1.18 + * accompanied this code).
1.19 + *
1.20 + * You should have received a copy of the GNU General Public License version
1.21 + * 2 along with this work; if not, write to the Free Software Foundation,
1.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1.23 + *
1.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1.25 + * or visit www.oracle.com if you need additional information or have any
1.26 + * questions.
1.27 + */
1.28 +
1.29 +package java.io;
1.30 +
1.31 +import java.io.ObjectOutput;
1.32 +import java.io.ObjectInput;
1.33 +
1.34 +/**
1.35 + * Only the identity of the class of an Externalizable instance is
1.36 + * written in the serialization stream and it is the responsibility
1.37 + * of the class to save and restore the contents of its instances.
1.38 + *
1.39 + * The writeExternal and readExternal methods of the Externalizable
1.40 + * interface are implemented by a class to give the class complete
1.41 + * control over the format and contents of the stream for an object
1.42 + * and its supertypes. These methods must explicitly
1.43 + * coordinate with the supertype to save its state. These methods supersede
1.44 + * customized implementations of writeObject and readObject methods.<br>
1.45 + *
1.46 + * Object Serialization uses the Serializable and Externalizable
1.47 + * interfaces. Object persistence mechanisms can use them as well. Each
1.48 + * object to be stored is tested for the Externalizable interface. If
1.49 + * the object supports Externalizable, the writeExternal method is called. If the
1.50 + * object does not support Externalizable and does implement
1.51 + * Serializable, the object is saved using
1.52 + * ObjectOutputStream. <br> When an Externalizable object is
1.53 + * reconstructed, an instance is created using the public no-arg
1.54 + * constructor, then the readExternal method called. Serializable
1.55 + * objects are restored by reading them from an ObjectInputStream.<br>
1.56 + *
1.57 + * An Externalizable instance can designate a substitution object via
1.58 + * the writeReplace and readResolve methods documented in the Serializable
1.59 + * interface.<br>
1.60 + *
1.61 + * @author unascribed
1.62 + * @see java.io.ObjectOutputStream
1.63 + * @see java.io.ObjectInputStream
1.64 + * @see java.io.ObjectOutput
1.65 + * @see java.io.ObjectInput
1.66 + * @see java.io.Serializable
1.67 + * @since JDK1.1
1.68 + */
1.69 +public interface Externalizable extends java.io.Serializable {
1.70 + /**
1.71 + * The object implements the writeExternal method to save its contents
1.72 + * by calling the methods of DataOutput for its primitive values or
1.73 + * calling the writeObject method of ObjectOutput for objects, strings,
1.74 + * and arrays.
1.75 + *
1.76 + * @serialData Overriding methods should use this tag to describe
1.77 + * the data layout of this Externalizable object.
1.78 + * List the sequence of element types and, if possible,
1.79 + * relate the element to a public/protected field and/or
1.80 + * method of this Externalizable class.
1.81 + *
1.82 + * @param out the stream to write the object to
1.83 + * @exception IOException Includes any I/O exceptions that may occur
1.84 + */
1.85 + void writeExternal(ObjectOutput out) throws IOException;
1.86 +
1.87 + /**
1.88 + * The object implements the readExternal method to restore its
1.89 + * contents by calling the methods of DataInput for primitive
1.90 + * types and readObject for objects, strings and arrays. The
1.91 + * readExternal method must read the values in the same sequence
1.92 + * and with the same types as were written by writeExternal.
1.93 + *
1.94 + * @param in the stream to read data from in order to restore the object
1.95 + * @exception IOException if I/O errors occur
1.96 + * @exception ClassNotFoundException If the class for an object being
1.97 + * restored cannot be found.
1.98 + */
1.99 + void readExternal(ObjectInput in) throws IOException, ClassNotFoundException;
1.100 +}