Class COSWriterObjectStream


  • public class COSWriterObjectStream
    extends java.lang.Object
    An instance of this class represents an object stream, that compresses a number of COSObjects 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.
    • Field Detail

      • LOG

        private static final org.apache.commons.logging.Log LOG
      • preparedKeys

        private final java.util.List<COSObjectKey> preparedKeys
      • preparedObjects

        private final java.util.List<COSBase> preparedObjects
    • 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.
      • writeObjectsToStream

        public COSStream writeObjectsToStream​(COSStream stream)
                                       throws java.io.IOException
        Writes all prepared COSObjects to the given COSStream.
        Parameters:
        stream - The stream for the compressed objects.
        Returns:
        The given COSStream of this object stream.
        Throws:
        java.io.IOException - Shall be thrown, if writing the object stream failed.
      • writeObject

        private void writeObject​(java.io.OutputStream output,
                                 COSBase object,
                                 boolean topLevel)
                          throws java.io.IOException
        This method prepares and writes COS data to the object stream by selecting appropriate specialized methods for the content.
        Parameters:
        output - The stream, that shall be written to.
        object - The content, that shall be written.
        topLevel - True, if the currently written object is a top level entry of this object stream.
        Throws:
        java.io.IOException - Shall be thrown, when an exception occurred for the write operation.
      • writeCOSString

        private void writeCOSString​(java.io.OutputStream output,
                                    COSString cosString)
                             throws java.io.IOException
        Write the given COSString to the given stream.
        Parameters:
        output - The stream, that shall be written to.
        cosString - The content, that shall be written.
        Throws:
        java.io.IOException
      • writeCOSFloat

        private void writeCOSFloat​(java.io.OutputStream output,
                                   COSFloat cosFloat)
                            throws java.io.IOException
        Write the given COSFloat to the given stream.
        Parameters:
        output - The stream, that shall be written to.
        cosFloat - The content, that shall be written.
        Throws:
        java.io.IOException
      • writeCOSInteger

        private void writeCOSInteger​(java.io.OutputStream output,
                                     COSInteger cosInteger)
                              throws java.io.IOException
        Write the given COSInteger to the given stream.
        Parameters:
        output - The stream, that shall be written to.
        cosInteger - The content, that shall be written.
        Throws:
        java.io.IOException
      • writeCOSBoolean

        private void writeCOSBoolean​(java.io.OutputStream output,
                                     COSBoolean cosBoolean)
                              throws java.io.IOException
        Write the given COSBoolean to the given stream.
        Parameters:
        output - The stream, that shall be written to.
        cosBoolean - The content, that shall be written.
        Throws:
        java.io.IOException
      • writeCOSName

        private void writeCOSName​(java.io.OutputStream output,
                                  COSName cosName)
                           throws java.io.IOException
        Write the given COSName to the given stream.
        Parameters:
        output - The stream, that shall be written to.
        cosName - The content, that shall be written.
        Throws:
        java.io.IOException
      • writeCOSArray

        private void writeCOSArray​(java.io.OutputStream output,
                                   COSArray cosArray)
                            throws java.io.IOException
        Write the given COSArray to the given stream.
        Parameters:
        output - The stream, that shall be written to.
        cosArray - The content, that shall be written.
        Throws:
        java.io.IOException
      • writeCOSDictionary

        private void writeCOSDictionary​(java.io.OutputStream output,
                                        COSDictionary cosDictionary)
                                 throws java.io.IOException
        Write the given COSDictionary to the given stream.
        Parameters:
        output - The stream, that shall be written to.
        cosDictionary - The content, that shall be written.
        Throws:
        java.io.IOException
      • writeObjectReference

        private void writeObjectReference​(java.io.OutputStream output,
                                          COSObjectKey indirectReference)
                                   throws java.io.IOException
        Write the given COSObjectKey to the given stream.
        Parameters:
        output - The stream, that shall be written to.
        indirectReference - The content, that shall be written.
        Throws:
        java.io.IOException
      • writeCOSNull

        private void writeCOSNull​(java.io.OutputStream output)
                           throws java.io.IOException
        Write COSNull to the given stream.
        Parameters:
        output - The stream, that shall be written to.
        Throws:
        java.io.IOException