brf.j2me.dynaworks.env
Interface Database

All Known Implementing Classes:
PalmDB, J9Database, KJavaDatabase

public interface Database

The Database interface describes a generalized persistence interface.

Version:
1.0
Author:
Bernd R. Fix

Field Summary
static int ERR_APPEND
          error appending a new record.
static int ERR_CREATE
          error: creation of database failed.
static int ERR_DBFULL
          error: database full.
static int ERR_DELETE
          error while deleting a record.
static int ERR_DEVICE
          device-related error.
static int ERR_NODATA
          error: no data available.
static int ERR_NODB
          error: requested database not found.
static int ERR_OPEN
          error: can't open database.
static int ERR_READ
          error while reading from database.
static int ERR_WRITE
          error writing the database.
static int S_OK
          success code.
 
Method Summary
 int addRecord(Dataset rec)
          add a record to the database.
 void close()
          Close the database.
 boolean deleteRecord(int idx)
          Delete a record at a specified index.
 int getErrorCode()
          return the current database error code.
 boolean getRecord(int idx, Dataset rec)
          Retreive a record from the database at a specific position.
 boolean isOpen()
          Is the database opened?
 int numberOfRecords()
          Return the number of records in the database.
 boolean open()
          Open the database.
 boolean putRecord(int idx, Dataset rec)
          Store a record in the database at a specific position.
 

Field Detail

S_OK

public static final int S_OK
success code.


ERR_CREATE

public static final int ERR_CREATE
error: creation of database failed.


ERR_OPEN

public static final int ERR_OPEN
error: can't open database.


ERR_NODB

public static final int ERR_NODB
error: requested database not found.


ERR_APPEND

public static final int ERR_APPEND
error appending a new record.


ERR_WRITE

public static final int ERR_WRITE
error writing the database.


ERR_DELETE

public static final int ERR_DELETE
error while deleting a record.


ERR_NODATA

public static final int ERR_NODATA
error: no data available.


ERR_READ

public static final int ERR_READ
error while reading from database.


ERR_DBFULL

public static final int ERR_DBFULL
error: database full.


ERR_DEVICE

public static final int ERR_DEVICE
device-related error.

Method Detail

getErrorCode

public int getErrorCode()
return the current database error code.

Returns:
int - error code.

open

public boolean open()
Open the database. If the database does not exist, it is created and then opened.

Returns:
boolean - Database opened?

isOpen

public boolean isOpen()
Is the database opened?

Returns:
boolean - Is the database opened?

close

public void close()
Close the database.


numberOfRecords

public int numberOfRecords()
Return the number of records in the database.

Returns:
int - Number of records in the database.

addRecord

public int addRecord(Dataset rec)
add a record to the database.

Parameters:
rec - Dataset - record to be added to the database.
Returns:
int - index of new record.
See Also:
Dataset

getRecord

public boolean getRecord(int idx,
                         Dataset rec)
Retreive a record from the database at a specific position.

Parameters:
idx - int - Position of the record in the database.
rec - Dataset - record to be filled with data.
Returns:
boolean - status of operation
See Also:
Dataset

putRecord

public boolean putRecord(int idx,
                         Dataset rec)
Store a record in the database at a specific position.

Parameters:
idx - int - Desired position of the record in the database.
rec - Dataset - record to be stored.
Returns:
boolean - Store successful?
See Also:
Dataset

deleteRecord

public boolean deleteRecord(int idx)
Delete a record at a specified index.

Parameters:
idx - int - Index of the record to be deleted.
Returns:
boolean - delete successful?