com.lizardtech.djvu
Class IFFInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by com.lizardtech.djvu.IFFInputStream
All Implemented Interfaces:
DjVuInterface, java.io.Closeable

public class IFFInputStream
extends java.io.InputStream
implements DjVuInterface

IFF files were originally intended for audio. But is well suited for any streaming data.


Field Summary
protected  com.lizardtech.djvu.IFFContext ctx
          The chunk information.
protected  java.io.DataInputStream input
          The input stream.
protected  java.io.InputStream input_raw
          The raw input stream.
protected  long offset
          The offset to the current location.
protected  long seekto
          The seekto location.
 
Constructor Summary
IFFInputStream()
          Creates a new IFFInputStream object.
IFFInputStream(DataPool dbs)
          Creates a new IFFInputStream object.
 
Method Summary
 void chunkClose()
          Close the current chunk.
static IFFInputStream createIFFInputStream(DjVuInterface ref)
          Creates an instance of IFFInputStream with the options interherited from the specified reference.
 DataPool getBSChunk()
          Retrieves a copy of the current chunk decoded with a BSInputStream into a new DataPool.
 BSInputStream getBSInputStream()
          Retrieve a copy of the current chunk and decodes it with a BSInputStream.
 DataPool getDataPool()
          Retrieve a copy of the current chunk as a DataPool object.
 DjVuOptions getDjVuOptions()
          Query the DjVuOptions used by this object.
 long getFilePointer()
          Query the current position.
 IFFInputStream init(DataPool dbs)
          Initialize this stream.
 boolean isComposite()
          Query if composite
 boolean isDjVuFile()
          This may be checked after attempting to read the first chunk to find out if the octet was present.
 int openChunk(java.lang.StringBuffer chkid)
          Get the next chunk id.
 int read()
          Read the next byte of the current chunk.
 int read(byte[] buffer, int off, int size)
          Read data from the current chunk.
 int ready()
          Query if data is available.
 void setDjVuOptions(DjVuOptions options)
          Set the DjVuOptions used by this object.
 long skip(long size)
          Skip bytes.
 
Methods inherited from class java.io.InputStream
available, close, mark, markSupported, read, reset
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

input

protected java.io.DataInputStream input
The input stream.


ctx

protected com.lizardtech.djvu.IFFContext ctx
The chunk information.


input_raw

protected java.io.InputStream input_raw
The raw input stream.


offset

protected long offset
The offset to the current location.


seekto

protected long seekto
The seekto location.

Constructor Detail

IFFInputStream

public IFFInputStream()
Creates a new IFFInputStream object.


IFFInputStream

public IFFInputStream(DataPool dbs)
Creates a new IFFInputStream object.

Parameters:
dbs - the data source
Method Detail

getBSChunk

public DataPool getBSChunk()
                    throws java.io.IOException
Retrieves a copy of the current chunk decoded with a BSInputStream into a new DataPool.

Returns:
the new DataPool.
Throws:
java.io.IOException - if an error occurs

getBSInputStream

public BSInputStream getBSInputStream()
                               throws java.io.IOException
Retrieve a copy of the current chunk and decodes it with a BSInputStream.

Returns:
the new BSInputStream
Throws:
java.io.IOException - if an error occurs

setDjVuOptions

public void setDjVuOptions(DjVuOptions options)
Set the DjVuOptions used by this object.

Specified by:
setDjVuOptions in interface DjVuInterface
Parameters:
options - The DjVuOptions used by this object.

getDjVuOptions

public DjVuOptions getDjVuOptions()
Query the DjVuOptions used by this object.

Specified by:
getDjVuOptions in interface DjVuInterface
Returns:
the DjVuOptions used by this object.

createIFFInputStream

public static IFFInputStream createIFFInputStream(DjVuInterface ref)
Creates an instance of IFFInputStream with the options interherited from the specified reference.

Parameters:
ref - Object to interherit DjVuOptions from.
Returns:
a new instance of IFFInputStream.

getDataPool

public DataPool getDataPool()
                     throws java.io.IOException
Retrieve a copy of the current chunk as a DataPool object.

Returns:
the new DataPool.
Throws:
java.io.IOException - if no chunk is open, or an io error occurs.

getFilePointer

public long getFilePointer()
                    throws java.io.IOException
Query the current position.

Returns:
the current position
Throws:
java.io.IOException - if an error occurs

chunkClose

public void chunkClose()
                throws java.io.IOException
Close the current chunk.

Throws:
java.io.IOException - if an error occurs

isComposite

public boolean isComposite()
Query if composite

Returns:
true if composite

openChunk

public int openChunk(java.lang.StringBuffer chkid)
              throws java.io.IOException
Get the next chunk id.

Parameters:
chkid - buffer to fill with id
Returns:
size if this chunk
Throws:
java.io.IOException - if an error occurs

init

public IFFInputStream init(DataPool dbs)
Initialize this stream.

Parameters:
dbs - data source
Returns:
the initialized stream

read

public int read(byte[] buffer,
                int off,
                int size)
         throws java.io.IOException
Read data from the current chunk.

Overrides:
read in class java.io.InputStream
Parameters:
buffer - byte array to fill
off - offset to start filling
size - maximum number of bytes to read
Returns:
the number of bytes read
Throws:
java.io.IOException - if an error occurs

read

public int read()
         throws java.io.IOException
Read the next byte of the current chunk.

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

ready

public int ready()
Query if data is available.

Returns:
true if data is available

isDjVuFile

public boolean isDjVuFile()
This may be checked after attempting to read the first chunk to find out if the octet was present.

Returns:
true if octet was present

skip

public long skip(long size)
          throws java.io.IOException
Skip bytes.

Overrides:
skip in class java.io.InputStream
Parameters:
size - number of bytes to skip.
Returns:
the number of bytes skipped
Throws:
java.lang.IllegalStateException - if an error occurs
java.io.IOException