com.gargoylesoftware.base.io

Class CondensedObjectOutputStream

public class CondensedObjectOutputStream extends ObjectOutputStream

A specialized subclass of ObjectOutputStream that is used to serialize objects. This stream will remove duplicate objects from the stream in order to shrink the resulting byte stream.

Only objects of the following types will be condensed: Character, Double, Integer, Long, Short and String. The biggest benefit will come from duplicate Strings.

Version: $Revision: 1.3 $

Author: Mike Bowler

Field Summary
Listclasses_
String[]classNames_
The list of classes that we can try condensing.
Listobjects_
Constructor Summary
CondensedObjectOutputStream(OutputStream stream)
Create the stream
Method Summary
protected ObjectreplaceObject(Object object)
Overrides the superclass to perform substitutions of duplicate immutable objects.

Field Detail

classes_

private final List classes_

classNames_

private final String[] classNames_
The list of classes that we can try condensing. Only classes that are immutable should be in this list.

objects_

private final List objects_

Constructor Detail

CondensedObjectOutputStream

public CondensedObjectOutputStream(OutputStream stream)
Create the stream

Parameters: stream The output stream that we are wrapping

Throws: IOException If the superclass throws an IOException in it's constructor.

Method Detail

replaceObject

protected Object replaceObject(Object object)
Overrides the superclass to perform substitutions of duplicate immutable objects.

Parameters: object The object to be serialized

Returns: Either the object that was passed in or an identical object that had previously been passed in.