org.pdfbox.pdmodel.common
Class COSStreamArray

java.lang.Object
  extended byorg.pdfbox.cos.COSBase
      extended byorg.pdfbox.cos.COSDictionary
          extended byorg.pdfbox.cos.COSStream
              extended byorg.pdfbox.pdmodel.common.COSStreamArray
All Implemented Interfaces:
COSObjectable

public class COSStreamArray
extends COSStream

This will take an array of streams and sequence them together.

Version:
$Revision: 1.9 $
Author:
Ben Litchfield

Constructor Summary
COSStreamArray(COSArray array)
          Constructor.
 
Method Summary
 Object accept(ICOSVisitor visitor)
          visitor pattern double dispatch method.
 void appendStream(COSStream streamToAppend)
          Appends a new stream to the array that represents this object's stream.
 OutputStream createFilteredStream()
          This will create a new stream for which filtered byte should be written to.
 OutputStream createFilteredStream(COSBase expectedLength)
          This will create a new stream for which filtered byte should be written to.
 OutputStream createUnfilteredStream()
          This will create an output stream that can be written to.
 COSDictionary getDictionary()
          This will get the dictionary that is associated with this stream.
 COSBase getDictionaryObject(COSName key)
          This will get an object from this streams dictionary and dereference it if necessary.
 InputStream getFilteredStream()
          This will get the stream with all of the filters applied.
 COSBase getFilters()
          This will return the filters to apply to the byte stream the method will return
 COSBase getItem(COSName key)
          This will get an object from this streams dictionary.
 RandomAccess getScratchFile()
          This will get the scratch file associated with this stream.
 List getStreamTokens()
          This will get all the tokens in the stream.
 InputStream getUnfilteredStream()
          This will get the logical content stream with none of the filters.
 void setFilters(COSBase filters)
          set the filters to be applied to the stream.
 String toString()
          
 
Methods inherited from class org.pdfbox.cos.COSStream
replaceWithStream
 
Methods inherited from class org.pdfbox.cos.COSDictionary
addAll, clear, containsValue, getBoolean, getBoolean, getDate, getDate, getDate, getDate, getDictionaryObject, getDictionaryObject, getDictionaryObject, getEmbeddedDate, getEmbeddedDate, getEmbeddedDate, getEmbeddedDate, getEmbeddedInt, getEmbeddedInt, getEmbeddedInt, getEmbeddedInt, getEmbeddedString, getEmbeddedString, getEmbeddedString, getEmbeddedString, getFloat, getFloat, getFloat, getFloat, getInt, getInt, getInt, getInt, getInt, getKeyForValue, getLong, getLong, getLong, getLong, getLong, getNameAsString, getNameAsString, getNameAsString, getNameAsString, getObjectFromPath, getString, getString, getString, getString, getValues, keyList, mergeInto, removeItem, setBoolean, setBoolean, setDate, setDate, setEmbeddedDate, setEmbeddedDate, setEmbeddedInt, setEmbeddedInt, setEmbeddedString, setEmbeddedString, setFloat, setFloat, setInt, setInt, setItem, setItem, setItem, setItem, setLong, setLong, setName, setName, setString, setString, size
 
Methods inherited from class org.pdfbox.cos.COSBase
getCOSObject, getFilterManager
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

COSStreamArray

public COSStreamArray(COSArray array)
Constructor.

Parameters:
array - The array of COSStreams to concatenate together.
Method Detail

getScratchFile

public RandomAccess getScratchFile()
This will get the scratch file associated with this stream.

Overrides:
getScratchFile in class COSStream
Returns:
The scratch file where this stream is being stored.

getItem

public COSBase getItem(COSName key)
This will get an object from this streams dictionary.

Overrides:
getItem in class COSDictionary
Parameters:
key - The key to the object.
Returns:
The dictionary object with the key or null if one does not exist.

getDictionaryObject

public COSBase getDictionaryObject(COSName key)
This will get an object from this streams dictionary and dereference it if necessary.

Overrides:
getDictionaryObject in class COSDictionary
Parameters:
key - The key to the object.
Returns:
The dictionary object with the key or null if one does not exist.

toString

public String toString()


getStreamTokens

public List getStreamTokens()
                     throws IOException
This will get all the tokens in the stream.

Overrides:
getStreamTokens in class COSStream
Returns:
All of the tokens in the stream.
Throws:
IOException - If there is an error parsing the stream.

getDictionary

public COSDictionary getDictionary()
This will get the dictionary that is associated with this stream.

Returns:
the object that is associated with this stream.

getFilteredStream

public InputStream getFilteredStream()
                              throws IOException
This will get the stream with all of the filters applied.

Overrides:
getFilteredStream in class COSStream
Returns:
the bytes of the physical (endoced) stream
Throws:
IOException - when encoding/decoding causes an exception

getUnfilteredStream

public InputStream getUnfilteredStream()
                                throws IOException
This will get the logical content stream with none of the filters.

Overrides:
getUnfilteredStream in class COSStream
Returns:
the bytes of the logical (decoded) stream
Throws:
IOException - when encoding/decoding causes an exception

accept

public Object accept(ICOSVisitor visitor)
              throws COSVisitorException
visitor pattern double dispatch method.

Overrides:
accept in class COSStream
Parameters:
visitor - The object to notify when visiting this object.
Returns:
any object, depending on the visitor implementation, or null
Throws:
COSVisitorException - If an error occurs while visiting this object.

getFilters

public COSBase getFilters()
This will return the filters to apply to the byte stream the method will return. - null if no filters are to be applied - a COSName if one filter is to be applied - a COSArray containing COSNames if multiple filters are to be applied

Overrides:
getFilters in class COSStream
Returns:
the COSBase object representing the filters

createFilteredStream

public OutputStream createFilteredStream()
                                  throws IOException
This will create a new stream for which filtered byte should be written to. You probably don't want this but want to use the createUnfilteredStream, which is used to write raw bytes to.

Overrides:
createFilteredStream in class COSStream
Returns:
A stream that can be written to.
Throws:
IOException - If there is an error creating the stream.

createFilteredStream

public OutputStream createFilteredStream(COSBase expectedLength)
                                  throws IOException
This will create a new stream for which filtered byte should be written to. You probably don't want this but want to use the createUnfilteredStream, which is used to write raw bytes to.

Overrides:
createFilteredStream in class COSStream
Parameters:
expectedLength - An entry where a length is expected.
Returns:
A stream that can be written to.
Throws:
IOException - If there is an error creating the stream.

setFilters

public void setFilters(COSBase filters)
                throws IOException
set the filters to be applied to the stream.

Overrides:
setFilters in class COSStream
Parameters:
filters - The filters to set on this stream.
Throws:
IOException - If there is an error clearing the old filters.

createUnfilteredStream

public OutputStream createUnfilteredStream()
                                    throws IOException
This will create an output stream that can be written to.

Overrides:
createUnfilteredStream in class COSStream
Returns:
An output stream which raw data bytes should be written to.
Throws:
IOException - If there is an error creating the stream.

appendStream

public void appendStream(COSStream streamToAppend)
Appends a new stream to the array that represents this object's stream.

Parameters:
streamToAppend - The stream to append.