org.garret.perst
Class NullFile

java.lang.Object
  extended byorg.garret.perst.NullFile
All Implemented Interfaces:
IFile

public class NullFile
extends java.lang.Object
implements IFile

This implementation of IFile interface can be used to make Perst an main-memory database. It should be used when pagePoolSize is set to Storage.INFINITE_PAGE_POOL. In this case all pages are cached in memory and NullFile is used just as a stub.

NullFile should be used only when data is transient - i.e. it should not be saved between database sessions. If you need in-memory database but which provide data persistency, you should use normal file and infinite page pool size.


Constructor Summary
NullFile()
           
 
Method Summary
 void close()
          Close file
 long length()
          Length of the file
 boolean lock()
          Lock file
 int read(long pos, byte[] buf)
          Reade data from the file
 void sync()
          Flush all fiels changes to the disk
 void write(long pos, byte[] buf)
          Write data to the file
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NullFile

public NullFile()
Method Detail

close

public void close()
Description copied from interface: IFile
Close file

Specified by:
close in interface IFile

length

public long length()
Description copied from interface: IFile
Length of the file

Specified by:
length in interface IFile

lock

public boolean lock()
Description copied from interface: IFile
Lock file

Specified by:
lock in interface IFile
Returns:
true if file was successfully locked or locking in not implemented, false if file is locked by some other applciation

read

public int read(long pos,
                byte[] buf)
Description copied from interface: IFile
Reade data from the file

Specified by:
read in interface IFile
Parameters:
pos - offset in the file
buf - array to receive readen data (size is always equal to database page size)
Returns:
number of bytes actually readen

sync

public void sync()
Description copied from interface: IFile
Flush all fiels changes to the disk

Specified by:
sync in interface IFile

write

public void write(long pos,
                  byte[] buf)
Description copied from interface: IFile
Write data to the file

Specified by:
write in interface IFile
Parameters:
pos - offset in the file
buf - array with data to be writter (size is always equal to database page size)