gov.sandia.cognition.io.serialization
Interface StreamSerializationHandler<SerializedType>

Type Parameters:
SerializedType - The type of object that can be serialized.
All Superinterfaces:
FileSerializationHandler<SerializedType>
All Known Subinterfaces:
TextSerializationHandler<SerializedType>
All Known Implementing Classes:
AbstractStreamSerializationHandler, AbstractTextSerializationHandler, GZIPSerializationHandler, JavaDefaultBinarySerializationHandler, XStreamSerializationHandler

public interface StreamSerializationHandler<SerializedType>
extends FileSerializationHandler<SerializedType>

Interface for an object that can be used to serialize and deserialize objects.

Since:
3.0
Author:
Justin Basilico

Method Summary
 Object convertFromBytes(byte[] bytes)
          Converts the first given object in the given byte array.
 byte[] convertToBytes(SerializedType object)
          Converts the given object to bytes.
 Object readObject(InputStream stream)
          Reads an object from the given stream.
 void writeObject(OutputStream stream, SerializedType object)
          Writes an object to a given output stream.
 
Methods inherited from interface gov.sandia.cognition.io.serialization.FileSerializationHandler
readFromFile, readFromFile, writeToFile, writeToFile
 

Method Detail

writeObject

void writeObject(OutputStream stream,
                 SerializedType object)
                 throws IOException
Writes an object to a given output stream.

Parameters:
stream - The stream to write the object to.
object - The object to write.
Throws:
IOException - If there is an i/o error.

readObject

Object readObject(InputStream stream)
                  throws IOException,
                         ClassNotFoundException
Reads an object from the given stream.

Parameters:
stream - The stream to read an object from.
Returns:
The object read from the stream.
Throws:
IOException - If there is an i/o error.
ClassNotFoundException - If a class cannot be found.

convertToBytes

byte[] convertToBytes(SerializedType object)
                      throws IOException
Converts the given object to bytes.

Parameters:
object - The object to convert to bytes.
Returns:
The byte representation of the object.
Throws:
IOException - If there is an i/o error.

convertFromBytes

Object convertFromBytes(byte[] bytes)
                        throws IOException,
                               ClassNotFoundException
Converts the first given object in the given byte array.

Parameters:
bytes - The bytes to convert the object from.
Returns:
The first object represented by the given bytes.
Throws:
IOException - If there is an i/o error.
ClassNotFoundException - If a class cannot be found.