org.apache.jcs.auxiliary.disk.indexed
Class IndexedDisk

java.lang.Object
  extended byorg.apache.jcs.auxiliary.disk.indexed.IndexedDisk

class IndexedDisk
extends java.lang.Object

Provides thread safe access to the underlying random access file.

Author:
asmuts

Field Summary
private  java.lang.String filepath
           
private static org.apache.commons.logging.Log log
           
private  java.io.RandomAccessFile raf
           
 
Constructor Summary
(package private) IndexedDisk(java.io.File file)
          Constructor for the Disk object
 
Method Summary
(package private)  boolean append(byte[] data)
          Appends byte array to the Disk.
(package private)  IndexedDiskElementDescriptor appendObject(CacheElement obj)
          Description of the Method
(package private)  void close()
          Closes the raf.
(package private)  long length()
          Returns the raf length.
(package private)  java.io.Serializable readObject(long pos)
          Description of the Method
(package private)  void reset()
          Sets the raf to empty.
(package private) static byte[] serialize(java.io.Serializable obj)
          Returns the serialized form of the given object in a byte array.
(package private)  boolean write(byte[] data, long pos)
          Writes the given byte array to the Disk at the specified position.
(package private)  boolean writeObject(java.io.Serializable obj, long pos)
          Description of the Method
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static final org.apache.commons.logging.Log log

filepath

private final java.lang.String filepath

raf

private java.io.RandomAccessFile raf
Constructor Detail

IndexedDisk

IndexedDisk(java.io.File file)
      throws java.io.FileNotFoundException
Constructor for the Disk object

Parameters:
file -
Throws:
java.io.FileNotFoundException
Method Detail

readObject

java.io.Serializable readObject(long pos)
Description of the Method

Parameters:
pos -
Returns:

append

boolean append(byte[] data)
Appends byte array to the Disk.

Parameters:
data -
Returns:

write

boolean write(byte[] data,
              long pos)
Writes the given byte array to the Disk at the specified position.

Parameters:
data -
pos -
Returns:

writeObject

boolean writeObject(java.io.Serializable obj,
                    long pos)
Description of the Method

Parameters:
obj -
pos -
Returns:

appendObject

IndexedDiskElementDescriptor appendObject(CacheElement obj)
Description of the Method

Parameters:
obj -
Returns:

length

long length()
      throws java.io.IOException
Returns the raf length.

Returns:
Throws:
java.io.IOException

close

void close()
     throws java.io.IOException
Closes the raf.

Throws:
java.io.IOException

reset

void reset()
     throws java.io.IOException
Sets the raf to empty.

Throws:
java.io.IOException

serialize

static byte[] serialize(java.io.Serializable obj)
                 throws java.io.IOException
Returns the serialized form of the given object in a byte array.

Parameters:
obj -
Returns:
Throws:
java.io.IOException