edu.harvard.hul.ois.jhove.module.pdf
Class Stream

java.lang.Object
  extended by edu.harvard.hul.ois.jhove.module.pdf.Token
      extended by edu.harvard.hul.ois.jhove.module.pdf.Stream

public class Stream
extends Token

Class to encapsulate a stream token. The content of the stream is not saved, only its length and starting offset.


Constructor Summary
Stream()
          Constructor.
 
Method Summary
 boolean advanceTo(int offset)
          Advances to a specified offset in the stream.
 long getLength()
          Returns the length of the stream.
 long getOffset()
          Returns the current offset in the stream.
 void initRead(java.io.RandomAccessFile raf)
          Prepares for reading the Stream.
 int read()
          Reads a byte from the Stream, applying the Filters if any.
 int read(byte[] b)
          Reads a sequence of bytes from the Stream, applying the Filters if any.
 int readAsciiInt()
          Reads an ASCII string, which may be preceded by white space.
 void setFilters(Filter[] filters)
          Sets the array of filters used by the stream.
 void setLength(long length)
          Sets the length field.
 void setOffset(long offset)
          Sets the offset field.
 long skipBytes(long n)
          Skips a specified number of bytes in the stream.
 
Methods inherited from class edu.harvard.hul.ois.jhove.module.pdf.Token
isPdfACompliant, isSimpleToken
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Stream

public Stream()
Constructor.

Method Detail

getLength

public long getLength()
Returns the length of the stream. This is 0, unless the Stream's setLength method has been called.


setLength

public void setLength(long length)
Sets the length field. This should be the length of the stream proper (not counting its dictionary) before filtering, in other words, the number of bytes stored in the file.


getOffset

public long getOffset()
Returns the current offset in the stream. This is -1, unless the Stream's setOffset method has been called.


setOffset

public void setOffset(long offset)
Sets the offset field.


setFilters

public void setFilters(Filter[] filters)
Sets the array of filters used by the stream. This must be called before initRead.


initRead

public void initRead(java.io.RandomAccessFile raf)
              throws java.io.IOException,
                     PdfException
Prepares for reading the Stream. If the filter List includes one which we don't support, throws a PdfException. This supports the abbreviated filter names in Appendix H of the PDF spec.

Throws:
java.io.IOException
PdfException

read

public int read()
         throws java.io.IOException
Reads a byte from the Stream, applying the Filters if any.

Throws:
java.io.IOException

read

public int read(byte[] b)
         throws java.io.IOException
Reads a sequence of bytes from the Stream, applying the Filters if any.

Throws:
java.io.IOException

skipBytes

public long skipBytes(long n)
               throws java.io.IOException
Skips a specified number of bytes in the stream.

Throws:
java.io.IOException

readAsciiInt

public int readAsciiInt()
                 throws java.io.IOException,
                        PdfException
Reads an ASCII string, which may be preceded by white space. Will eat the first white space character after the ASCII string.

Throws:
java.io.IOException
PdfException

advanceTo

public boolean advanceTo(int offset)
                  throws java.io.IOException
Advances to a specified offset in the stream. The offset is defined as the number of decompressed bytes which precede the position in the stream. Returns true if the advance is successful, false if the point has already been passed or some other failure occurs.

Throws:
java.io.IOException