fop 1.0

org.apache.fop.pdf
Class AbstractPDFStream

java.lang.Object
  extended by org.apache.fop.pdf.PDFObject
      extended by org.apache.fop.pdf.PDFDictionary
          extended by org.apache.fop.pdf.AbstractPDFStream
All Implemented Interfaces:
PDFWritable
Direct Known Subclasses:
AbstractPDFFontStream, PDFStream, PDFXObject

public abstract class AbstractPDFStream
extends PDFDictionary

This is an abstract base class for PDF streams.


Field Summary
 
Fields inherited from class org.apache.fop.pdf.PDFDictionary
entries, order
 
Fields inherited from class org.apache.fop.pdf.PDFObject
DATE_FORMAT, log
 
Constructor Summary
AbstractPDFStream()
          Constructor for AbstractPDFStream.
 
Method Summary
protected  int encodeAndWriteStream(java.io.OutputStream out, PDFNumber refLength)
          Encodes and writes a stream directly to an OutputStream.
protected  StreamCache encodeStream()
          Encodes the raw data stream for output to a PDF file.
protected  java.lang.String getDefaultFilterName()
          Returns the name of a suitable filter for this PDF object.
 PDFFilterList getFilterList()
          Returns the associated filter list.
protected abstract  int getSizeHint()
          Returns a value that hints at the size of the encoded stream.
protected  int output(java.io.OutputStream stream)
          Overload the base object method so we don't have to copy byte arrays around so much Write the PDF represention of this object
protected abstract  void outputRawStreamData(java.io.OutputStream out)
          Sends the raw stream data to the target OutputStream.
protected  int outputStreamData(StreamCache encodedStream, java.io.OutputStream out)
          Output just the stream data enclosed by stream/endstream markers
protected  void populateStreamDict(java.lang.Object lengthEntry)
          Populates the dictionary with all necessary entries for the stream.
protected  void prepareImplicitFilters()
          Prepares implicit filters (such as the DCTFilter for JPEG images).
protected  void setupFilterList()
          Sets up the default filters for this stream if they haven't been set from outside.
 
Methods inherited from class org.apache.fop.pdf.PDFDictionary
get, put, put, writeDictionary
 
Methods inherited from class org.apache.fop.pdf.PDFObject
contentEquals, encode, encodeBinaryToHexString, encodeString, encodeText, formatDateTime, formatDateTime, formatObject, getDocument, getDocumentSafely, getGeneration, getObjectID, getObjectNumber, getParent, hasObjectNumber, makeReference, outputInline, referencePDF, setDocument, setObjectNumber, setParent, toPDF, toPDFString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractPDFStream

public AbstractPDFStream()
Constructor for AbstractPDFStream.

Method Detail

setupFilterList

protected void setupFilterList()
Sets up the default filters for this stream if they haven't been set from outside.


getDefaultFilterName

protected java.lang.String getDefaultFilterName()
Returns the name of a suitable filter for this PDF object.

Returns:
the default filter
See Also:
PDFFilterList

getFilterList

public PDFFilterList getFilterList()
Returns the associated filter list.

Returns:
the filter list

getSizeHint

protected abstract int getSizeHint()
                            throws java.io.IOException
Returns a value that hints at the size of the encoded stream. This is used to optimize buffer allocation so fewer buffer reallocations are necessary.

Returns:
an estimated size (0 if no hint can be given)
Throws:
java.io.IOException - in case of an I/O problem

outputRawStreamData

protected abstract void outputRawStreamData(java.io.OutputStream out)
                                     throws java.io.IOException
Sends the raw stream data to the target OutputStream.

Parameters:
out - OutputStream to write to
Throws:
java.io.IOException - In case of an I/O problem

outputStreamData

protected int outputStreamData(StreamCache encodedStream,
                               java.io.OutputStream out)
                        throws java.io.IOException
Output just the stream data enclosed by stream/endstream markers

Parameters:
encodedStream - already encoded/filtered stream to write
out - OutputStream to write to
Returns:
int number of bytes written
Throws:
java.io.IOException - in case of an I/O problem

encodeStream

protected StreamCache encodeStream()
                            throws java.io.IOException
Encodes the raw data stream for output to a PDF file.

Returns:
the encoded stream
Throws:
java.io.IOException - in case of an I/O problem

encodeAndWriteStream

protected int encodeAndWriteStream(java.io.OutputStream out,
                                   PDFNumber refLength)
                            throws java.io.IOException
Encodes and writes a stream directly to an OutputStream. The length of the stream, in this case, is set on a PDFNumber object that has to be prepared beforehand.

Parameters:
out - OutputStream to write to
refLength - PDFNumber object to receive the stream length
Returns:
number of bytes written (header and trailer included)
Throws:
java.io.IOException - in case of an I/O problem

output

protected int output(java.io.OutputStream stream)
              throws java.io.IOException
Overload the base object method so we don't have to copy byte arrays around so much Write the PDF represention of this object

Overrides:
output in class PDFDictionary
Parameters:
stream - the stream to write the PDF to
Returns:
the number of bytes written
Throws:
java.io.IOException - if there is an error writing to the stream

populateStreamDict

protected void populateStreamDict(java.lang.Object lengthEntry)
Populates the dictionary with all necessary entries for the stream. Override this method if you need additional entries.

Parameters:
lengthEntry - value for the /Length entry

prepareImplicitFilters

protected void prepareImplicitFilters()
Prepares implicit filters (such as the DCTFilter for JPEG images). You must make sure that the appropriate filters are in the filter list at the right places.


fop 1.0

Copyright 1999-2010 The Apache Software Foundation. All Rights Reserved.