public interface Streamable
ObjectOutputStream
instances and read from ObjectInputStream instances.
All non-transient, non-NotStreamable fields will be automatically written
and restored for a Streamable instance. Classes that wish to stream transient fields or
customize the streaming process should implement methods with the following signatures:
public void writeObject (ObjectOutputStream out);
public void readObject (ObjectInputStream in);
They can then handle the entirety of the streaming process, or call ObjectOutputStream.defaultWriteObject() and ObjectInputStream.defaultReadObject() from
within their writeObject and readObject methods to perform the standard
streaming in addition to their customized behavior.
Streamable classes must either have a zero-argument constructor, in which case any number of other constructors are allowed, but the zero-argument constructor will be used when unserializing an instance; or they must have exactly one non-zero-argument constructor, and that constructor will be called when unserializing an instance with "zero/null" values (meaning all primitive types will be passed the appropriate zero value, and all reference types will be passed null. This latter approach can even be used by classes with final fields, as the zero/null values will be overwritten during unstreaming.
| Modifier and Type | Interface and Description |
|---|---|
static interface |
Streamable.Closure
A marker interface for streamable classes that expect to be extended anonymously, but for
which the implicit outer class reference can (and should) be ignored.
|
Copyright © 2015. All rights reserved.