org.icepdf.core.pobjects.filters
Class ChunkingInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by org.icepdf.core.pobjects.filters.ChunkingInputStream
All Implemented Interfaces:
java.io.Closeable
Direct Known Subclasses:
ASCII85Decode, ASCIIHexDecode, FlateDecode, LZWDecode, PredictorDecode, RunLengthDecode

public abstract class ChunkingInputStream
extends java.io.InputStream

Most of the filters have to read in a chunk of data from their input stream, and do some processing on it, before they can make it available to others

Since:
2.0
Author:
Mark Collette

Field Summary
protected  byte[] buffer
           
protected  java.io.InputStream in
           
 
Constructor Summary
ChunkingInputStream()
           
 
Method Summary
 int available()
           
 void close()
           
protected  int fillBufferFromInputStream()
          For some reason, when reading from InflaterInputStream, if we ask to fill a buffer, it will instead only give us a chunk at a time, even though more data is available, and buffer.length has bee requested
protected  int fillBufferFromInputStream(int offset, int length)
           
protected abstract  int fillInternalBuffer()
          This is only called if bufferAvailable is 0.
 void mark(int readlimit)
           
 boolean markSupported()
           
 int read()
           
 int read(byte[] b)
           
 int read(byte[] b, int off, int length)
           
 void reset()
           
protected  void setBufferSize(int size)
           
protected  void setInputStream(java.io.InputStream input)
           
 long skip(long n)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

in

protected java.io.InputStream in

buffer

protected byte[] buffer
Constructor Detail

ChunkingInputStream

public ChunkingInputStream()
Method Detail

setInputStream

protected void setInputStream(java.io.InputStream input)

setBufferSize

protected void setBufferSize(int size)

fillBufferFromInputStream

protected int fillBufferFromInputStream()
                                 throws java.io.IOException
For some reason, when reading from InflaterInputStream, if we ask to fill a buffer, it will instead only give us a chunk at a time, even though more data is available, and buffer.length has bee requested

Throws:
java.io.IOException

fillBufferFromInputStream

protected int fillBufferFromInputStream(int offset,
                                        int length)
                                 throws java.io.IOException
Throws:
java.io.IOException

fillInternalBuffer

protected abstract int fillInternalBuffer()
                                   throws java.io.IOException
This is only called if bufferAvailable is 0. Implementations should read in more data, and return how many bytes are now available

Throws:
java.io.IOException

markSupported

public boolean markSupported()
Overrides:
markSupported in class java.io.InputStream

mark

public void mark(int readlimit)
Overrides:
mark in class java.io.InputStream

reset

public void reset()
           throws java.io.IOException
Overrides:
reset in class java.io.InputStream
Throws:
java.io.IOException

read

public int read()
         throws java.io.IOException
Specified by:
read in class java.io.InputStream
Throws:
java.io.IOException

read

public int read(byte[] b)
         throws java.io.IOException
Overrides:
read in class java.io.InputStream
Throws:
java.io.IOException

read

public int read(byte[] b,
                int off,
                int length)
         throws java.io.IOException
Overrides:
read in class java.io.InputStream
Throws:
java.io.IOException

skip

public long skip(long n)
          throws java.io.IOException
Overrides:
skip in class java.io.InputStream
Throws:
java.io.IOException

available

public int available()
              throws java.io.IOException
Overrides:
available in class java.io.InputStream
Throws:
java.io.IOException

close

public void close()
           throws java.io.IOException
Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.io.InputStream
Throws:
java.io.IOException

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object