org.xerial.db.storage
Class MemoryFile

java.lang.Object
  extended by org.xerial.db.storage.MemoryFile
All Implemented Interfaces:
DBFile

public class MemoryFile
extends Object
implements DBFile

MemoryFile is a class to handle main memory as if it were a file

Author:
leo

Constructor Summary
MemoryFile()
           
 
Method Summary
 void close()
          Closes the file.
 void loadFromFile(String fileName)
           
 void read(byte[] buffer, int offset, int byteSize)
          Reads data from the file, and writes the read data to the specified buffer
 void seek(long fileBytePos)
          Sets the file pointer offset, measured from the beginning of the file, at which the next read/write request occurs.
 void write(byte[] buffer, int offset, int byteSize)
          Writes the given data into the file
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MemoryFile

public MemoryFile()
Method Detail

loadFromFile

public void loadFromFile(String fileName)
                  throws IOException,
                         DBException
Throws:
IOException
DBException

read

public void read(byte[] buffer,
                 int offset,
                 int byteSize)
          throws DBException
Description copied from interface: DBFile
Reads data from the file, and writes the read data to the specified buffer

Specified by:
read in interface DBFile
Parameters:
buffer - the buffer into which the data is read
offset - the start offset in the buffer at which the data is written
byteSize - the bytes to read
Throws:
DBException

seek

public void seek(long fileBytePos)
          throws DBException
Description copied from interface: DBFile
Sets the file pointer offset, measured from the beginning of the file, at which the next read/write request occurs. The fileBytePos can exceed the end of the file. Setting the fileBytePos higher than the end of the file does not expand the file size. The size will change by writing after the offset has been set beyond the end of the file.

Specified by:
seek in interface DBFile
Throws:
DBException

write

public void write(byte[] buffer,
                  int offset,
                  int byteSize)
           throws DBException
Description copied from interface: DBFile
Writes the given data into the file

Specified by:
write in interface DBFile
Parameters:
buffer - the data
offset - the start offset in the data
byteSize - the bytes to write
Throws:
DBException

close

public void close()
           throws DBException
Description copied from interface: DBFile
Closes the file.

Specified by:
close in interface DBFile
Throws:
DBException


Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 2.1 Japan License.