Package org.apache.pdfbox.pdmodel.common
Class COSStreamArray
- java.lang.Object
-
- org.apache.pdfbox.cos.COSBase
-
- org.apache.pdfbox.cos.COSDictionary
-
- org.apache.pdfbox.cos.COSStream
-
- org.apache.pdfbox.pdmodel.common.COSStreamArray
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,COSObjectable
public class COSStreamArray extends COSStream
This will take an array of streams and sequence them together.- Version:
- $Revision: 1.10 $
- Author:
- Ben Litchfield
-
-
Field Summary
-
Fields inherited from class org.apache.pdfbox.cos.COSDictionary
items
-
-
Constructor Summary
Constructors Constructor Description COSStreamArray(COSArray array)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Objectaccept(ICOSVisitor visitor)visitor pattern double dispatch method.voidappendStream(COSStream streamToAppend)Appends a new stream to the array that represents this object's stream.java.io.OutputStreamcreateFilteredStream()This will create a new stream for which filtered byte should be written to.java.io.OutputStreamcreateFilteredStream(COSBase expectedLength)This will create a new stream for which filtered byte should be written to.java.io.OutputStreamcreateUnfilteredStream()This will create an output stream that can be written to.COSBaseget(int index)This will get a stream (or the reference to a stream) from the array.COSDictionarygetDictionary()This will get the dictionary that is associated with this stream.COSBasegetDictionaryObject(COSName key)This will get an object from this streams dictionary and dereference it if necessary.java.io.InputStreamgetFilteredStream()This will get the stream with all of the filters applied.COSBasegetFilters()This will return the filters to apply to the byte stream the method will returnCOSBasegetItem(COSName key)This will get an object from this streams dictionary.RandomAccessgetScratchFile()This will get the scratch file associated with this stream.intgetStreamCount()This will get the number of streams in the array.java.util.ListgetStreamTokens()This will get all the tokens in the stream.java.io.InputStreamgetUnfilteredStream()This will get the logical content stream with none of the filters.voidinsertCOSStream(PDStream streamToBeInserted)Insert the given stream at the beginning of the existing stream array.voidsetFilters(COSBase filters)set the filters to be applied to the stream.java.lang.StringtoString()-
Methods inherited from class org.apache.pdfbox.cos.COSStream
close, getFilteredLength, getFilteredLengthWritten, replaceWithStream, setFilteredLength
-
Methods inherited from class org.apache.pdfbox.cos.COSDictionary
addAll, clear, containsKey, containsKey, containsValue, entrySet, getBoolean, getBoolean, getBoolean, getDate, getDate, getDate, getDate, getDictionaryObject, getDictionaryObject, getDictionaryObject, getDictionaryObject, getEmbeddedDate, getEmbeddedDate, getEmbeddedDate, getEmbeddedDate, getEmbeddedInt, getEmbeddedInt, getEmbeddedInt, getEmbeddedInt, getEmbeddedString, getEmbeddedString, getEmbeddedString, getEmbeddedString, getFloat, getFloat, getFloat, getFloat, getInt, getInt, getInt, getInt, getInt, getInt, getInt, getItem, getKeyForValue, getLong, getLong, getLong, getLong, getLong, getNameAsString, getNameAsString, getNameAsString, getNameAsString, getObjectFromPath, getString, getString, getString, getString, getValues, keyList, keySet, 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.apache.pdfbox.cos.COSBase
getCOSObject, getFilterManager, isDirect, isNeedToBeUpdate, setDirect, setNeedToBeUpdate
-
-
-
-
Constructor Detail
-
COSStreamArray
public COSStreamArray(COSArray array)
Constructor.- Parameters:
array- The array of COSStreams to concatenate together.
-
-
Method Detail
-
get
public COSBase get(int index)
This will get a stream (or the reference to a stream) from the array.- Parameters:
index- The index of the requested stream- Returns:
- The stream object or a reference to a stream
-
getStreamCount
public int getStreamCount()
This will get the number of streams in the array.- Returns:
- the number of streams
-
getScratchFile
public RandomAccess getScratchFile()
This will get the scratch file associated with this stream.- Overrides:
getScratchFilein classCOSStream- 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:
getItemin classCOSDictionary- 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:
getDictionaryObjectin classCOSDictionary- Parameters:
key- The key to the object.- Returns:
- The dictionary object with the key or null if one does not exist.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classCOSDictionary
-
getStreamTokens
public java.util.List getStreamTokens() throws java.io.IOExceptionThis will get all the tokens in the stream.- Overrides:
getStreamTokensin classCOSStream- Returns:
- All of the tokens in the stream.
- Throws:
java.io.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 java.io.InputStream getFilteredStream() throws java.io.IOExceptionThis will get the stream with all of the filters applied.- Overrides:
getFilteredStreamin classCOSStream- Returns:
- the bytes of the physical (endoced) stream
- Throws:
java.io.IOException- when encoding/decoding causes an exception
-
getUnfilteredStream
public java.io.InputStream getUnfilteredStream() throws java.io.IOExceptionThis will get the logical content stream with none of the filters.- Overrides:
getUnfilteredStreamin classCOSStream- Returns:
- the bytes of the logical (decoded) stream
- Throws:
java.io.IOException- when encoding/decoding causes an exception
-
accept
public java.lang.Object accept(ICOSVisitor visitor) throws COSVisitorException
visitor pattern double dispatch method.- Overrides:
acceptin classCOSStream- 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:
getFiltersin classCOSStream- Returns:
- the COSBase object representing the filters
-
createFilteredStream
public java.io.OutputStream createFilteredStream() throws java.io.IOExceptionThis 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:
createFilteredStreamin classCOSStream- Returns:
- A stream that can be written to.
- Throws:
java.io.IOException- If there is an error creating the stream.
-
createFilteredStream
public java.io.OutputStream createFilteredStream(COSBase expectedLength) throws java.io.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:
createFilteredStreamin classCOSStream- Parameters:
expectedLength- An entry where a length is expected.- Returns:
- A stream that can be written to.
- Throws:
java.io.IOException- If there is an error creating the stream.
-
setFilters
public void setFilters(COSBase filters) throws java.io.IOException
set the filters to be applied to the stream.- Overrides:
setFiltersin classCOSStream- Parameters:
filters- The filters to set on this stream.- Throws:
java.io.IOException- If there is an error clearing the old filters.
-
createUnfilteredStream
public java.io.OutputStream createUnfilteredStream() throws java.io.IOExceptionThis will create an output stream that can be written to.- Overrides:
createUnfilteredStreamin classCOSStream- Returns:
- An output stream which raw data bytes should be written to.
- Throws:
java.io.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.
-
insertCOSStream
public void insertCOSStream(PDStream streamToBeInserted)
Insert the given stream at the beginning of the existing stream array.- Parameters:
streamToBeInserted-
-
-