com.lizardtech.djvu
Class DataPool.CachedInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by com.lizardtech.djvu.DataPool.CachedInputStream
All Implemented Interfaces:
java.io.Closeable
Enclosing class:
DataPool

public class DataPool.CachedInputStream
extends java.io.InputStream

This class is an input stream which spans the accessable data in a DataPool object.

Version:
$Revision: 1.10 $
Author:
Bill C. Riemers

Constructor Summary
DataPool.CachedInputStream()
          Creates a new CachedInputStream object.
 
Method Summary
 int available()
          Query how much data is available without blocking.
 DataPool createDataPool(int size)
          Create a DataPool representing this input stream.
 void mark(int readLimit)
          Marks the current location for a reset() later.
 boolean markSuppoted()
          Query if mark is supported.
 int read()
          Read the next byte of data ranged 0 to 255.
 int read(byte[] b, int off, int len)
          Read data into an array of bytes.
 int read16()
          Read the next two bytes as a posative integer.
 int read24()
          Read the next three bytes as a posative integer.
 int read8()
          Read the next bytes as a posative integer.
 java.lang.String readUTF(int size)
          Read up to the specified number of bytes as a String.
 void reset()
          Restore the marked position
 long skip(long n)
          Skip bytes without reading.
 
Methods inherited from class java.io.InputStream
close, markSupported, read
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataPool.CachedInputStream

public DataPool.CachedInputStream()
Creates a new CachedInputStream object.

Method Detail

available

public int available()
Query how much data is available without blocking.

Overrides:
available in class java.io.InputStream
Returns:
number of buffered bytes

createDataPool

public DataPool createDataPool(int size)
Create a DataPool representing this input stream.

Parameters:
size - the amount of data in the DataPool
Returns:
the newly created DataPool

mark

public void mark(int readLimit)
Marks the current location for a reset() later.

Overrides:
mark in class java.io.InputStream
Parameters:
readLimit - ignored

markSuppoted

public boolean markSuppoted()
Query if mark is supported.

Returns:
true

read

public int read()
         throws java.io.IOException
Read the next byte of data ranged 0 to 255. Returns -1 if an EOF has been read.

Specified by:
read in class java.io.InputStream
Returns:
next byte
Throws:
java.io.IOException - if an error occurs

read

public int read(byte[] b,
                int off,
                int len)
         throws java.io.IOException
Read data into an array of bytes.

Overrides:
read in class java.io.InputStream
Parameters:
b - byte array to copy data to
off - byte array offset to start copying to
len - maximum number of bytes to copy
Returns:
number of bytes read
Throws:
java.io.IOException

read16

public int read16()
Read the next two bytes as a posative integer. If EOF is reached, then return -1.

Returns:
the value read

read24

public int read24()
Read the next three bytes as a posative integer. If EOF is reached, then return -1.

Returns:
the value read

read8

public int read8()
Read the next bytes as a posative integer. If EOF is reached, then return -1.

Returns:
the value read

readUTF

public java.lang.String readUTF(int size)
                         throws java.io.IOException
Read up to the specified number of bytes as a String. If conversion from java modified UTF8 fails, then the string will be interpreted using the current locale encoding.

Parameters:
size - maximum number of bytes to read
Returns:
the newly created string
Throws:
java.io.IOException - if an error occurs

reset

public void reset()
           throws java.io.IOException
Restore the marked position

Overrides:
reset in class java.io.InputStream
Throws:
java.io.IOException - if an error occurs

skip

public long skip(long n)
          throws java.io.IOException
Skip bytes without reading.

Overrides:
skip in class java.io.InputStream
Parameters:
n - number of bytes to skip
Returns:
number of bytes actually skipped
Throws:
java.io.IOException - if an error occurs