com.lizardtech.djvu
Class DataPool

java.lang.Object
  extended by com.lizardtech.djvu.DjVuObject
      extended by com.lizardtech.djvu.DataPool
All Implemented Interfaces:
DjVuInterface

public class DataPool
extends DjVuObject

This class implements a random access mapping of input streams and URL connections. For input streams and non-http connections, the mapping is achieved by reading in all the data into memory. Http streams are mapped by reading in data blocks when needed.

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

Field Summary
static int BLOCKSIZE
          The default size of each block.
static java.util.Hashtable cache
          Object for caching raw data.
 
Fields inherited from class com.lizardtech.djvu.DjVuObject
hasReferences
 
Constructor Summary
DataPool()
          Creates a new DataPool object.
 
Method Summary
static DataPool createDataPool(DjVuInterface ref)
          Creates an instance of DataPool with the options interherited from the specified reference.
 byte[] getBlock(int index, boolean read)
          Request the specified block of data.
 int getCurrentSize()
          Query the largest read end offset.
 int getEndOffset()
          Query the size of this vector.
 DataPool init(java.io.InputStream input)
          Initialize this map to read the specified stream
 DataPool init(java.net.URL url)
          Initialize this map to read the specified URL.
protected  void setEndOffset(int offset)
          Set the end position.
 
Methods inherited from class com.lizardtech.djvu.DjVuObject
checkLockTime, create, create, createSoftReference, createWeakReference, getDjVuOptions, getFromReference, invoke, logError, printStackTrace, setDjVuOptions, verbose
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BLOCKSIZE

public static final int BLOCKSIZE
The default size of each block.

See Also:
Constant Field Values

cache

public static java.util.Hashtable cache
Object for caching raw data. !

Constructor Detail

DataPool

public DataPool()
Creates a new DataPool object.

Method Detail

createDataPool

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

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

init

public DataPool init(java.net.URL url)
Initialize this map to read the specified URL. If a cached DataPool for this URL exists, it will be returned.

Parameters:
url - the URL to read
Returns:
an initialized DataPool

init

public DataPool init(java.io.InputStream input)
Initialize this map to read the specified stream

Parameters:
input - the InputStream to read
Returns:
the initialized DataPool

getCurrentSize

public int getCurrentSize()
Query the largest read end offset.

Returns:
the largest read end offset

getBlock

public byte[] getBlock(int index,
                       boolean read)
Request the specified block of data. Data may be buffered, or read.

Parameters:
index - the position of the block start position divided by BLOCKSIZE.
read - True if unavailable blocks should be read from the data source.
Returns:
a byte array up to size BLOCKSIZE, or null if no data is available.

setEndOffset

protected void setEndOffset(int offset)
Set the end position. This value may only be reduced, never increased.

Parameters:
offset - new end offset

getEndOffset

public int getEndOffset()
Query the size of this vector.

Returns:
the size of this vector