org.fjank.jcache.persistence
Class CacheFileAdapter

java.lang.Object
  extended by org.fjank.jcache.persistence.CacheFileAdapter

public class CacheFileAdapter
extends Object

Provides thread safe access to the underlying random access file.


Constructor Summary
CacheFileAdapter(File file)
          Creates a new CacheFileAdapter object.
 
Method Summary
 void append(byte[] data)
           
 org.fjank.jcache.persistence.DiskElementDescriptor appendObject(CacheObject obj)
          adds an object to the diskcache.
 void close()
           
static DiskCacheObject deSerialize(byte[] data)
           
 long length()
           
 byte[] read(long pos)
          reads from the diskfile, and return the raw bytes contained at that pos.
 Serializable readObject(long pos)
          reads an object starting at the position,.
 void reset()
           
static byte[] serialize(Serializable obj)
           
 String toString()
          returns a String representation of this object.
 void write(byte[] data, long pos)
           
 void writeObject(Serializable obj, long pos)
          writes an object down to the cachefile
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CacheFileAdapter

public CacheFileAdapter(File file)
Creates a new CacheFileAdapter object.

Parameters:
file - the file to adapt to
Throws:
DiskCacheException - if any exceptioins occur.
Method Detail

toString

public String toString()
returns a String representation of this object.

Overrides:
toString in class Object
Returns:
a String representation of this object.

read

public byte[] read(long pos)
reads from the diskfile, and return the raw bytes contained at that pos. Its up to the client to deSerialize.

Parameters:
pos - the position to start at.
Returns:
a byte[] containing the raw bytes for the object.

readObject

public Serializable readObject(long pos)
                        throws DiskCacheException
reads an object starting at the position,.

Parameters:
pos - the position to start at
Returns:
a Serializable object read from the diskcache.
Throws:
DiskCacheException
DiskCacheException - if any exceptions occur.

append

public void append(byte[] data)
            throws DiskCacheException
Throws:
DiskCacheException

write

public void write(byte[] data,
                  long pos)

writeObject

public void writeObject(Serializable obj,
                        long pos)
writes an object down to the cachefile

Parameters:
obj - the object to write
pos - the position to start at.
Throws:
DiskCacheException - if any exception occur.

appendObject

public org.fjank.jcache.persistence.DiskElementDescriptor appendObject(CacheObject obj)
adds an object to the diskcache.

Parameters:
obj - the object to add.
Returns:
a disk element descriptor used to locate the object
Throws:
DiskCacheException - if any exceptions occur.

length

public long length()

close

public void close()

reset

public void reset()

serialize

public static byte[] serialize(Serializable obj)

deSerialize

public static DiskCacheObject deSerialize(byte[] data)
                                   throws DiskCacheException
Throws:
DiskCacheException


Copyright © 2002-2009 Hosted by SourceForge. All Rights Reserved.