public abstract class Streamer extends Object
Streamable instances as well as a set of basic object types
(see ObjectOutputStream). An instance of Streamer is created for each distinct
class that implements Streamable. The Streamer reflects on the streamed class
and caches the information necessary to efficiently read and write objects of the class in
question.| Modifier and Type | Method and Description |
|---|---|
abstract Object |
createObject(ObjectInputStream in)
Creates a blank object that can subsequently be read by this streamer.
|
static Class<?> |
getCollectionClass(Class<?> clazz)
If the specified class is not Streamable and is a Collection type, return the
most specific supported Collection interface type; otherwise return null.
|
static Streamer |
getStreamer(Class<?> target)
Obtains a
Streamer that can be used to read and write objects of the specified
target class. |
static Class<?> |
getStreamerClass(Object object)
Returns the class that should be used when streaming this object.
|
static boolean |
isStreamable(Class<?> target)
Returns true if the supplied target class can be streamed using a streamer.
|
abstract void |
readObject(Object object,
ObjectInputStream in,
boolean useReader)
Reads and populates the fields of the supplied object from the specified stream.
|
String |
toString() |
abstract void |
writeObject(Object object,
ObjectOutputStream out,
boolean useWriter)
Writes the supplied object to the specified stream.
|
public static boolean isStreamable(Class<?> target)
public static Class<?> getStreamerClass(Object object)
public static Class<?> getCollectionClass(Class<?> clazz)
public static Streamer getStreamer(Class<?> target) throws IOException
Streamer that can be used to read and write objects of the specified
target class. Streamer instances are shared among all ObjectInputStreams and
ObjectOutputStreams.target - the class that is desired to be streamed. This should be the result of a call
to getStreamerClass(java.lang.Object) if the caller has an instance they wish to stream.IOException - when a streamer is requested for an object that does not implement
Streamable and is not one of the basic object types (@see ObjectOutputStream).public abstract void writeObject(Object object, ObjectOutputStream out, boolean useWriter) throws IOException
object - the instance to be written to the stream.out - the stream to which to write the instance.useWriter - whether or not to use the custom writeObject if one exists.IOExceptionpublic abstract Object createObject(ObjectInputStream in) throws IOException, ClassNotFoundException
IOExceptionClassNotFoundExceptionpublic abstract void readObject(Object object, ObjectInputStream in, boolean useReader) throws IOException, ClassNotFoundException
object - the instance to be read from the stream.in - the stream from which to read the instance.useReader - whether or not to use the custom readObject if one exists.IOExceptionClassNotFoundExceptionCopyright © 2015. All rights reserved.