gov.sandia.cognition.io.serialization
Class GZIPSerializationHandler<SerializedType>

java.lang.Object
  extended by gov.sandia.cognition.util.AbstractCloneableSerializable
      extended by gov.sandia.cognition.io.serialization.AbstractFileSerializationHandler<SerializedType>
          extended by gov.sandia.cognition.io.serialization.AbstractStreamSerializationHandler<SerializedType>
              extended by gov.sandia.cognition.io.serialization.GZIPSerializationHandler<SerializedType>
Type Parameters:
SerializedType - The type of object that can be serialized.
All Implemented Interfaces:
FileSerializationHandler<SerializedType>, StreamSerializationHandler<SerializedType>, CloneableSerializable, Serializable, Cloneable

public class GZIPSerializationHandler<SerializedType>
extends AbstractStreamSerializationHandler<SerializedType>

Implements a serialization handler that uses the GZip compression algorithm on the output. Can wrap any stream serialization handler.

Since:
3.0
Author:
Justin Basilico
See Also:
Serialized Form

Field Summary
protected  StreamSerializationHandler<SerializedType> baseHandler
          The base handler that is being wrapped in a GZip.
 
Constructor Summary
GZIPSerializationHandler()
          Creates a new GZIPSerializationHandler that uses the default JavaBinarySerializationHandler.
GZIPSerializationHandler(StreamSerializationHandler<SerializedType> baseHandler)
          Creates a new GZIPSerializationHandler that will use the given base handler.
 
Method Summary
 StreamSerializationHandler<SerializedType> getBaseHandler()
          Gets the base handler whose output is serialized.
 Object readObject(InputStream stream)
          Reads an object from the given stream.
 void setBaseHandler(StreamSerializationHandler<SerializedType> baseHandler)
          Sets the base handler whose output is serialized.
 void writeObject(OutputStream stream, SerializedType object)
          Writes an object to a given output stream.
 
Methods inherited from class gov.sandia.cognition.io.serialization.AbstractStreamSerializationHandler
convertFromBytes, convertToBytes, readFromFile, writeToFile
 
Methods inherited from class gov.sandia.cognition.io.serialization.AbstractFileSerializationHandler
readFromFile, writeToFile
 
Methods inherited from class gov.sandia.cognition.util.AbstractCloneableSerializable
clone
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface gov.sandia.cognition.io.serialization.FileSerializationHandler
readFromFile, writeToFile
 

Field Detail

baseHandler

protected StreamSerializationHandler<SerializedType> baseHandler
The base handler that is being wrapped in a GZip.

Constructor Detail

GZIPSerializationHandler

public GZIPSerializationHandler()
Creates a new GZIPSerializationHandler that uses the default JavaBinarySerializationHandler.


GZIPSerializationHandler

public GZIPSerializationHandler(StreamSerializationHandler<SerializedType> baseHandler)
Creates a new GZIPSerializationHandler that will use the given base handler.

Parameters:
baseHandler - The base handler to use with the gzip.
Method Detail

writeObject

public void writeObject(OutputStream stream,
                        SerializedType object)
                 throws IOException
Description copied from interface: StreamSerializationHandler
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

public Object readObject(InputStream stream)
                  throws IOException,
                         ClassNotFoundException
Description copied from interface: StreamSerializationHandler
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.

getBaseHandler

public StreamSerializationHandler<SerializedType> getBaseHandler()
Gets the base handler whose output is serialized.

Returns:
The base handler.

setBaseHandler

public void setBaseHandler(StreamSerializationHandler<SerializedType> baseHandler)
Sets the base handler whose output is serialized.

Parameters:
baseHandler - The base handler.