org.xerial.db.storage
Interface DBFile

All Known Implementing Classes:
DiskFile, MemoryFile

public interface DBFile

An interface to access disk files, or main memory buffers. Accesses to the DBFile are not guaranteed to be thread-safe, that is, concurrent accesses to the DBFile may cause undesired effects; for example, contiguous write requests may overwrite the previous write results because the second write request can be performed before the file cursor is properly updated.

Author:
leo

Method Summary
 void close()
          Closes the file.
 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
 

Method Detail

read

void read(byte[] buffer,
          int offset,
          int byteSize)
          throws DBException
Reads data from the file, and writes the read data to the specified buffer

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:
DBFileException - when failed to read the data
DBException

write

void write(byte[] buffer,
           int offset,
           int byteSize)
           throws DBException
Writes the given data into the file

Parameters:
buffer - the data
offset - the start offset in the data
byteSize - the bytes to write
Throws:
DBFileException - when failed to write the data
DBException

seek

void seek(long fileBytePos)
          throws DBException
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.

Parameters:
fileBytePos -
Throws:
DBFileException
DBException

close

void close()
           throws DBException
Closes the file.

Throws:
DBFileException
DBException


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