org.apache.pdfbox.pdfwriter.compress

## Class COSWriterObjectStream

- java.lang.Object
- - org.apache.pdfbox.pdfwriter.compress.COSWriterObjectStream

    public class COSWriterObjectStream
    extends Object

An instance of this class represents an object stream, that compresses a number of `COSObject`s in a stream. It may be added to the top level container of a written PDF document in place of the compressed objects. The document's `PDFXRefStream` must be adapted accordingly.

Author:
  Christian Appl

### Constructor Summary

Constructors
Constructor and Description
`COSWriterObjectStream(COSWriterCompressionPool compressionPool)` Creates an object stream for compressible objects from the given `COSWriterCompressionPool`.

### Method Summary

All Methods Instance Methods Concrete Methods
`List<COSObjectKey>` `getPreparedKeys()` Returns all `COSObjectKey`s, that shall be added to the object stream, when `writeObjectsToStream(COSStream)` is called.
`void` `prepareStreamObject(COSObjectKey key, COSBase object)` Prepares the given `COSObject` to be written to this object stream, using the given `COSObjectKey` as it's ID for indirect references.
`COSStream` `writeObjectsToStream(COSStream stream)` Writes all prepared `COSObject`s to the given `COSStream`.

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

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

### Constructor Detail

#### COSWriterObjectStream

    public COSWriterObjectStream(COSWriterCompressionPool compressionPool)

Creates an object stream for compressible objects from the given `COSWriterCompressionPool`. The objects must first be prepared for this object stream, by adding them via calling `prepareStreamObject(COSObjectKey, COSBase)` and will be written to this `COSStream`, when `writeObjectsToStream(COSStream)` is called.

Parameters:
  `compressionPool` - The compression pool an object stream shall be created for.

### Method Detail

#### prepareStreamObject

    public void prepareStreamObject(COSObjectKey key,
                                    COSBase object)

Prepares the given `COSObject` to be written to this object stream, using the given `COSObjectKey` as it's ID for indirect references.

Parameters:
  `key` - The `COSObjectKey`, that shall be used for indirect references to the `COSObject`.
  `object` - The `COSObject`, that shall be written to this object stream.

#### getPreparedKeys

    public List<COSObjectKey> getPreparedKeys()

Returns all `COSObjectKey`s, that shall be added to the object stream, when `writeObjectsToStream(COSStream)` is called.

Returns:
  All `COSObjectKey`s, that shall be added to the object stream.

#### writeObjectsToStream

    public COSStream writeObjectsToStream(COSStream stream)
                                   throws IOException

Writes all prepared `COSObject`s to the given `COSStream`.

Parameters:
  `stream` - The stream for the compressed objects.
Returns:
  The given `COSStream` of this object stream.
Throws:
  `IOException` - Shall be thrown, if writing the object stream failed.