solve the performance problems associated with
making a class
Serializable, the serialization
mechanism allows you to declare that a class is
writeObject( ) method is
called, it performs the following sequence of
It tests to see if the object is an instance
Externalizable. If so, it uses
externalization to marshall the object.
If the object isn’t an instance of
Externalizable, it tests
to see whether the object is an instance of
If so, it uses serialization to marshall the
If neither of these two cases apply, an exception is thrown.
is an interface that consists of two methods:
public void readExternal(ObjectInput in); public void writeExternal(ObjectOutput out);
These have roughly the
same role that
readObject( ) and
writeObject( ) have for
serialization. There are, however, some very
important differences. The first, and most
obvious, is that
readExternal( ) and
writeExternal( ) are
part of the
Externalizable interface. An object
cannot be declared to be
Externalizable without implementing
However, the major difference lies in how these methods are used. The serialization mechanism always writes out class descriptions of all the serializable superclasses. And it always writes out the information associated with the instance when viewed as an instance of each individual superclasses.
Externalization gets rid of some of this. It ...