Class COSWriterObjectStream
- java.lang.Object
-
- org.apache.pdfbox.pdfwriter.compress.COSWriterObjectStream
-
public class COSWriterObjectStream extends java.lang.ObjectAn instance of this class represents an object stream, that compresses a number ofCOSObjects 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'sPDFXRefStreammust be adapted accordingly.
-
-
Field Summary
Fields Modifier and Type Field Description private COSWriterCompressionPoolcompressionPoolprivate static org.apache.commons.logging.LogLOGprivate java.util.List<COSObjectKey>preparedKeysprivate java.util.List<COSBase>preparedObjects
-
Constructor Summary
Constructors Constructor Description COSWriterObjectStream(COSWriterCompressionPool compressionPool)Creates an object stream for compressible objects from the givenCOSWriterCompressionPool.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.List<COSObjectKey>getPreparedKeys()Returns allCOSObjectKeys, that shall be added to the object stream, whenwriteObjectsToStream(COSStream)is called.voidprepareStreamObject(COSObjectKey key, COSBase object)Prepares the givenCOSObjectto be written to this object stream, using the givenCOSObjectKeyas it's ID for indirect references.private voidwriteCOSArray(java.io.OutputStream output, COSArray cosArray)Write the givenCOSArrayto the given stream.private voidwriteCOSBoolean(java.io.OutputStream output, COSBoolean cosBoolean)Write the givenCOSBooleanto the given stream.private voidwriteCOSDictionary(java.io.OutputStream output, COSDictionary cosDictionary)Write the givenCOSDictionaryto the given stream.private voidwriteCOSFloat(java.io.OutputStream output, COSFloat cosFloat)Write the givenCOSFloatto the given stream.private voidwriteCOSInteger(java.io.OutputStream output, COSInteger cosInteger)Write the givenCOSIntegerto the given stream.private voidwriteCOSName(java.io.OutputStream output, COSName cosName)Write the givenCOSNameto the given stream.private voidwriteCOSNull(java.io.OutputStream output)WriteCOSNullto the given stream.private voidwriteCOSString(java.io.OutputStream output, COSString cosString)Write the givenCOSStringto the given stream.private voidwriteObject(java.io.OutputStream output, COSBase object, boolean topLevel)This method prepares and writes COS data to the object stream by selecting appropriate specialized methods for the content.private voidwriteObjectReference(java.io.OutputStream output, COSObjectKey indirectReference)Write the givenCOSObjectKeyto the given stream.COSStreamwriteObjectsToStream(COSStream stream)
-
-
-
Field Detail
-
LOG
private static final org.apache.commons.logging.Log LOG
-
compressionPool
private final COSWriterCompressionPool compressionPool
-
preparedKeys
private final java.util.List<COSObjectKey> preparedKeys
-
preparedObjects
private final java.util.List<COSBase> preparedObjects
-
-
Constructor Detail
-
COSWriterObjectStream
public COSWriterObjectStream(COSWriterCompressionPool compressionPool)
Creates an object stream for compressible objects from the givenCOSWriterCompressionPool. The objects must first be prepared for this object stream, by adding them via callingprepareStreamObject(COSObjectKey, COSBase)and will be written to thisCOSStream, whenwriteObjectsToStream(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 givenCOSObjectto be written to this object stream, using the givenCOSObjectKeyas it's ID for indirect references.- Parameters:
key- TheCOSObjectKey, that shall be used for indirect references to theCOSObject.object- TheCOSObject, that shall be written to this object stream.
-
getPreparedKeys
public java.util.List<COSObjectKey> getPreparedKeys()
Returns allCOSObjectKeys, that shall be added to the object stream, whenwriteObjectsToStream(COSStream)is called.- Returns:
- All
COSObjectKeys, that shall be added to the object stream.
-
writeObjectsToStream
public COSStream writeObjectsToStream(COSStream stream) throws java.io.IOException
- Parameters:
stream- The stream for the compressed objects.- Returns:
- The given
COSStreamof 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.IOExceptionThis 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.IOExceptionWrite the givenCOSStringto 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.IOExceptionWrite the givenCOSFloatto 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.IOExceptionWrite the givenCOSIntegerto 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.IOExceptionWrite the givenCOSBooleanto 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.IOExceptionWrite the givenCOSNameto 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.IOExceptionWrite the givenCOSArrayto 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.IOExceptionWrite the givenCOSDictionaryto 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.IOExceptionWrite the givenCOSObjectKeyto 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.IOExceptionWriteCOSNullto the given stream.- Parameters:
output- The stream, that shall be written to.- Throws:
java.io.IOException
-
-