Class CondensedObjectOutputStream

java.lang.Object
java.io.OutputStream
java.io.ObjectOutputStream
com.gargoylesoftware.base.io.CondensedObjectOutputStream
All Implemented Interfaces:
Closeable, DataOutput, Flushable, ObjectOutput, ObjectStreamConstants, AutoCloseable

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 $
  • Field Details

    • classNames_

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

      private final List classes_
    • objects_

      private final List objects_
  • Constructor Details

    • CondensedObjectOutputStream

      public CondensedObjectOutputStream(OutputStream stream) throws IOException
      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 Details

    • replaceObject

      protected Object replaceObject(Object object)
      Overrides the superclass to perform substitutions of duplicate immutable objects.
      Overrides:
      replaceObject in class ObjectOutputStream
      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.