com.etymon.pjx
Class PdfStream

java.lang.Object
  extended by com.etymon.pjx.PdfObject
      extended by com.etymon.pjx.PdfStream
All Implemented Interfaces:
java.lang.Cloneable

public class PdfStream
extends PdfObject

Represents the PDF stream object. This class is synchronized.


Field Summary
protected  java.nio.ByteBuffer _bb
          The byte sequence contained by the stream.
protected  PdfDictionary _d
          The stream dictionary.
protected static PdfName PDFNAME_LENGTH
          A PdfName object representing the name Length.
 
Constructor Summary
protected PdfStream()
          A protected constructor intended to be called only from wrap(PdfDictionary, ByteByffer).
  PdfStream(PdfDictionary d, java.nio.ByteBuffer bb)
          Constructs a stream object from a PDF dictionary and a ByteBuffer.
 
Method Summary
 boolean equals(java.lang.Object obj)
          Compares this instance with another PDF object for equality.
 java.nio.ByteBuffer getBuffer()
          Returns the byte sequence contained in this stream.
 PdfDictionary getDictionary()
          Returns this stream's dictionary.
 int hashCode()
          Returns a hash code for this object.
protected static PdfStream wrap(PdfDictionary d, java.nio.ByteBuffer bb)
          A factory for fast construction of this class.
protected  int writePdf(PdfWriter w, boolean spacing)
          Writes this object in PDF format.
 
Methods inherited from class com.etymon.pjx.PdfObject
clone, filter, filterContents, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

_bb

protected java.nio.ByteBuffer _bb
The byte sequence contained by the stream. The position is maintained at 0, and the limit is maintained at capacity().


_d

protected PdfDictionary _d
The stream dictionary.


PDFNAME_LENGTH

protected static final PdfName PDFNAME_LENGTH
A PdfName object representing the name Length.

Constructor Detail

PdfStream

protected PdfStream()
A protected constructor intended to be called only from wrap(PdfDictionary, ByteByffer).


PdfStream

public PdfStream(PdfDictionary d,
                 java.nio.ByteBuffer bb)
Constructs a stream object from a PDF dictionary and a ByteBuffer. The stream's byte sequence is read from the ByteBuffer starting at its current position and ending at its limit.

Parameters:
d - the PDF dictionary.
bb - the ByteBuffer.
Method Detail

getBuffer

public java.nio.ByteBuffer getBuffer()
Returns the byte sequence contained in this stream.

Returns:
the byte sequence. The returned ByteBuffer object is read-only.

getDictionary

public PdfDictionary getDictionary()
Returns this stream's dictionary.

Returns:
the stream dictionary.

wrap

protected static PdfStream wrap(PdfDictionary d,
                                java.nio.ByteBuffer bb)
A factory for fast construction of this class. The constructed object will be a wrapper around the specified PdfDictionary and ByteBuffer. The entire capacity of ByteBuffer is assumed to represent the stream's byte sequence. The Length value in the stream dictionary is assumed to be correct. The calling method must ensure that the ByteBuffer is never externally modified or accessed, in order to meet the immutability requirement of PdfObject.

Parameters:
m - the PdfDictionary and ByteBuffer to be used to back this stream.
Returns:
the constructed object.

writePdf

protected int writePdf(PdfWriter w,
                       boolean spacing)
                throws java.io.IOException
Description copied from class: PdfObject
Writes this object in PDF format.

Specified by:
writePdf in class PdfObject
Parameters:
w - the PdfWriter to write to.
spacing - specifies whether to add white-space before the object. A value of true enables the addition of white-space. If the object begins with a PDF delimiter, then this option is ignored and no white-space is written.
Returns:
the number of bytes written by this method.
Throws:
java.io.IOException

equals

public boolean equals(java.lang.Object obj)
Description copied from class: PdfObject
Compares this instance with another PDF object for equality.

Overrides:
equals in class PdfObject
Parameters:
obj - the object to compare this instance with.
Returns:
true if the PDF objects are equal.

hashCode

public int hashCode()
Description copied from class: PdfObject
Returns a hash code for this object.

Overrides:
hashCode in class PdfObject
Returns:
the hash code.