nl.uva.vlet.vrs
Interface VRandomAccessable

All Known Implementing Classes:
VFile

public interface VRandomAccessable

Provides some RandomAccessFile methods (java.io.RandomAccessFile) which are shared by some VFS implementations. (Currently localfs and SRB).
Note that this interface does NOT define seek,skip methods since this is an interface to a remote file. No filedescriptors, etc are kept alive !
All methods should be Atomic. Parallel write (currently) results in undefined behaviour as no lock methods are provided yet.
Although parallel writes to diferrent offsets in the same file should work!. This is not tested.

See Also:
RandomAccessFile, VStreamReadable, VStreamWritable

Method Summary
 int readBytes(long fileOffset, byte[] buffer, int bufferOffset, int nrBytes)
          Reads nrBytes from file starting to read from fileOffset.
 void setLengthToZero()
          Resets file length to zero.
Currently setLength() is not supported by SRB so this method is currently the only method which can decrease the file size.
 void writeBytes(long fileOffset, byte[] buffer, int bufferOffset, int nrBytes)
          Writes nrBytes to the file starting at position fileOffset in the file.
 

Method Detail

setLengthToZero

void setLengthToZero()
                     throws VlException
Resets file length to zero.
Currently setLength() is not supported by SRB so this method is currently the only method which can decrease the file size.
To extend a file, use writeBytes to append data to a file.

Throws:
VlException

readBytes

int readBytes(long fileOffset,
              byte[] buffer,
              int bufferOffset,
              int nrBytes)
              throws VlException
Reads nrBytes from file starting to read from fileOffset. Data is stored into the byte array buffer[] starting at bufferOffset.

Throws:
VlException
See Also:
RandomAccessFile.readBytes(byte[], int, int)

writeBytes

void writeBytes(long fileOffset,
                byte[] buffer,
                int bufferOffset,
                int nrBytes)
                throws VlException
Writes nrBytes to the file starting at position fileOffset in the file. Data is and reading from byte array buffer[bufferOffset].

Throws:
VlException
See Also:
RandomAccessFile.writeBytes(byte[], int, int)