FileDocCategorySizeDatePackage
AbstractRecordStoreFile.javaAPI DocphoneME MR2 API (J2ME)5578Wed May 02 18:00:12 BST 2007com.sun.midp.rms

AbstractRecordStoreFile

public interface AbstractRecordStoreFile
A RecordStoreFile is a file abstraction layer between a a RecordStore and an underlying persistent storage mechanism. The underlying storage methods are provided by the RandomAccessStream and File classes. RecordStoreFile confines the namespace of a record store to the scope of the MIDlet suite of its creating application. It also ensures unicode recordstore names are ascii filesystem safe. The RecordStoreImpl class can be implemented directly using the RandomAccessStream and File classes. However, RecordStoreFile served as the java/native code boundary for RMS in the MIDP 1.0 release. It exists now for backwards compatibility with older ports.

Fields Summary
static final int
DB_EXTENSION
extension for RecordStore database files
static final int
IDX_EXTENSION
extension for RecordStore database files
Constructors Summary
Methods Summary
public voidclose()
Disconnect from recordStream if it is non null. May be called more than once without error.

exception
IOException if an error occurs closing recordStream.

public voidcommitWrite()
Commit pending writes

exception
IOException if an error occurs while flushing recordStream.

public intread(byte[] buf)
Read up to buf.length into buf.

param
buf buffer to read in to.
return
the number of bytes read.
exception
IOException if a read error occurs.

public intread(byte[] buf, int offset, int numBytes)
Read up to buf.length into buf starting at offset offset in recordStream and continuing for up to numBytes bytes.

param
buf buffer to read in to.
param
offset starting point read offset, from beginning of buffer.
param
numBytes the number of bytes to read.
return
the number of bytes read.
exception
IOException if a read error occurs.

public voidseek(int pos)
Sets the position within recordStream to pos. This will implicitly grow the underlying stream if pos is made greater than the current length of the storage stream.

param
pos position within the file to move the current_pos pointer to.
exception
IOException if there is a problem with the seek.

public intspaceAvailable(int suiteId)
Approximation of remaining space in storage. Usage Warning: This may be a slow operation if the platform has to look at the size of each file stored in the MIDP memory space and include its size in the total.

param
suiteId ID of the MIDlet suite that owns the record store can be null
return
the approximate space available to grow the record store in bytes.

public voidtruncate(int size)
Sets the length of this RecordStoreFile size bytes. If this file was previously larger than size the extra data is lost. size must be <= the current length of recordStream

param
size new size for this file.
exception
IOException if an error occurs, or if size is less than zero.

public voidwrite(byte[] buf)
Write all of buf to recordStream.

param
buf buffer to read out of.
exception
IOException if a write error occurs.

public voidwrite(byte[] buf, int offset, int numBytes)
Write buf to recordStream, starting at offset and continuing for numBytes bytes.

param
buf buffer to read out of.
param
offset starting point write offset, from beginning of buffer.
param
numBytes the number of bytes to write.
exception
IOException if a write error occurs.