Package com.sleepycat.bind.serial

## Class SerialOutput

- java.lang.Object
- - java.io.OutputStream
  - - java.io.ObjectOutputStream
    - - com.sleepycat.bind.serial.SerialOutput

- All Implemented Interfaces:
    `java.io.Closeable`, `java.io.DataOutput`, `java.io.Flushable`, `java.io.ObjectOutput`, `java.io.ObjectStreamConstants`, `java.lang.AutoCloseable`

      public class SerialOutput
      extends java.io.ObjectOutputStream

  A specialized `ObjectOutputStream` that stores class description information in a `ClassCatalog`. It is used by `SerialBinding`.

  This class is used instead of an `ObjectOutputStream`, which it extends, to write a compact object stream. For writing objects to a database normally one of the serial binding classes is used. `SerialOutput` is used when an `ObjectOutputStream` is needed along with compact storage. A `ClassCatalog` must be supplied, however, to stored shared class descriptions.

  The `ClassCatalog` is used to store class definitions rather than embedding these into the stream. Instead, a class format identifier is embedded into the stream. This identifier is then used by `SerialInput` to load the class format to deserialize the object.

  See Also:
    Class Evolution

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class java.io.ObjectOutputStream

      `java.io.ObjectOutputStream.PutField`

  - ### Field Summary

    - ### Fields inherited from interface java.io.ObjectStreamConstants

      `baseWireHandle, PROTOCOL_VERSION_1, PROTOCOL_VERSION_2, SC_BLOCK_DATA, SC_ENUM, SC_EXTERNALIZABLE, SC_SERIALIZABLE, SC_WRITE_METHOD, SERIAL_FILTER_PERMISSION, STREAM_MAGIC, STREAM_VERSION, SUBCLASS_IMPLEMENTATION_PERMISSION, SUBSTITUTION_PERMISSION, TC_ARRAY, TC_BASE, TC_BLOCKDATA, TC_BLOCKDATALONG, TC_CLASS, TC_CLASSDESC, TC_ENDBLOCKDATA, TC_ENUM, TC_EXCEPTION, TC_LONGSTRING, TC_MAX, TC_NULL, TC_OBJECT, TC_PROXYCLASSDESC, TC_REFERENCE, TC_RESET, TC_STRING`

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `SerialOutput​(java.io.OutputStream out, ClassCatalog classCatalog)` | Creates a serial output stream.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `static byte[]` | `getStreamHeader()` | Returns the fixed stream header used for all serialized streams in PROTOCOL_VERSION_2 format.
    `protected void` | `writeClassDescriptor​(java.io.ObjectStreamClass classdesc)` |

    - ### Methods inherited from class java.io.ObjectOutputStream

      `annotateClass, annotateProxyClass, close, defaultWriteObject, drain, enableReplaceObject, flush, putFields, replaceObject, reset, useProtocolVersion, write, write, write, writeBoolean, writeByte, writeBytes, writeChar, writeChars, writeDouble, writeFields, writeFloat, writeInt, writeLong, writeObject, writeObjectOverride, writeShort, writeStreamHeader, writeUnshared, writeUTF`

    - ### Methods inherited from class java.io.OutputStream

      `nullOutputStream`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### SerialOutput

          public SerialOutput​(java.io.OutputStream out,
                              ClassCatalog classCatalog)
                       throws java.io.IOException

      Creates a serial output stream.
      Parameters:
        `out` - is the output stream to which the compact serialized objects will be written.
        `classCatalog` - is the catalog to which the class descriptions for the serialized objects will be written.
      Throws:
        `java.io.IOException` - if an I/O error occurs while writing stream header.

  - ### Method Detail

    - #### writeClassDescriptor

          protected void writeClassDescriptor​(java.io.ObjectStreamClass classdesc)
                                       throws java.io.IOException

      Overrides:
        `writeClassDescriptor` in class `java.io.ObjectOutputStream`
      Throws:
        `java.io.IOException`

    - #### getStreamHeader

          public static byte[] getStreamHeader()

      Returns the fixed stream header used for all serialized streams in PROTOCOL_VERSION_2 format. To save space this header can be removed and serialized streams before storage and inserted before deserializing. `SerialOutput` always uses PROTOCOL_VERSION_2 serialization format to guarantee that this header is fixed. `SerialBinding` removes this header from serialized streams automatically.
      Returns:
        the fixed stream header.

Copyright (c) 1996, 2020 Oracle and/or its affiliates. All rights reserved.