com.imagero.uio.buffer
Class RAFBufferManager

java.lang.Object
  extended bycom.imagero.uio.buffer.AbstractBufferManager
      extended bycom.imagero.uio.buffer.RAFBufferManager
All Implemented Interfaces:
BufferManager
Direct Known Subclasses:
MutableRAFBufferManager

public class RAFBufferManager
extends AbstractBufferManager


Field Summary
protected  java.io.RandomAccessFile raf
           
 
Fields inherited from class com.imagero.uio.buffer.AbstractBufferManager
defaultBufferSize
 
Fields inherited from interface com.imagero.uio.buffer.BufferManager
empty
 
Constructor Summary
RAFBufferManager(java.io.RandomAccessFile raf)
           
RAFBufferManager(java.io.RandomAccessFile raf, long offset)
           
RAFBufferManager(java.io.RandomAccessFile raf, long offset, long length)
          create MutableBuffer for RandomAccessRO (with standard Buffer length of 50k)
RAFBufferManager(java.io.RandomAccessFile raf, long offset, long length, int dsLength)
          create MutableBuffer for RandomAccessRO
 
Method Summary
 void clear()
          clear all buffered data without closing
 void close()
          Allows to free all possibly used resources
protected  Buffer createBuffer(java.io.RandomAccessFile raf, long offset, int dsLength)
           
 byte[] getData(int i)
          get data (as byte array) from i'th Buffer
protected  byte[] getDataImpl(int i)
          read i'th Buffer
 int getDataLength(int i)
          get length of i'th Buffer
 long getDataStart(int i)
          get start of i'th Buffer in byte
I assume here that length of each Buffer (except last one) equals to dsLength
 int getIndex(long pos)
          get index of Buffer which contains pos
 long getLength()
          get length of data
 
Methods inherited from class com.imagero.uio.buffer.AbstractBufferManager
clear, clearImpl, createAccessManager, flush, getCount, getDefaultBufferSize, getEnd, getMaxCache, getStart, setDefaultBufferSize, setDirty, setDirty, setMaxCache
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

raf

protected java.io.RandomAccessFile raf
Constructor Detail

RAFBufferManager

public RAFBufferManager(java.io.RandomAccessFile raf)
                 throws java.io.IOException

RAFBufferManager

public RAFBufferManager(java.io.RandomAccessFile raf,
                        long offset)
                 throws java.io.IOException

RAFBufferManager

public RAFBufferManager(java.io.RandomAccessFile raf,
                        long offset,
                        long length)
create MutableBuffer for RandomAccessRO (with standard Buffer length of 50k)

See Also:
RABufferRO

RAFBufferManager

public RAFBufferManager(java.io.RandomAccessFile raf,
                        long offset,
                        long length,
                        int dsLength)
create MutableBuffer for RandomAccessRO

Parameters:
dsLength - standard length of one data block of Buffer
See Also:
RABufferRO
Method Detail

createBuffer

protected Buffer createBuffer(java.io.RandomAccessFile raf,
                              long offset,
                              int dsLength)

getData

public byte[] getData(int i)
               throws java.io.IOException
get data (as byte array) from i'th Buffer

Parameters:
i - Buffer index
Returns:
byte array
Throws:
java.io.IOException - if i'th Buffer not exists and couldn't be read

getDataImpl

protected byte[] getDataImpl(int i)
                      throws java.io.IOException
read i'th Buffer

Parameters:
i - Buffer index
Returns:
byte array
Throws:
java.io.IOException

getDataLength

public int getDataLength(int i)
get length of i'th Buffer

Parameters:
i - Buffer index
Returns:
dsLength

getIndex

public int getIndex(long pos)
get index of Buffer which contains pos

Parameters:
pos -
Returns:
index of Buffer or -1

getLength

public long getLength()
get length of data


getDataStart

public long getDataStart(int i)
get start of i'th Buffer in byte
I assume here that length of each Buffer (except last one) equals to dsLength

Parameters:
i -
Returns:
int
                          n-1
dataStart(n) = Σ getDataLength(i)
                          i=0

close

public void close()
Description copied from interface: BufferManager
Allows to free all possibly used resources


clear

public void clear()
Description copied from interface: BufferManager
clear all buffered data without closing

Specified by:
clear in interface BufferManager
Overrides:
clear in class AbstractBufferManager