brf.j2me.dynaworks.db.palm
Class PalmDB

java.lang.Object
  |
  +--brf.j2me.dynaworks.db.palm.PalmDB
All Implemented Interfaces:
Database
Direct Known Subclasses:
AddressDB, DatebookDB, ExpenseDB, MailDB, MemoDB, TodoDB

public class PalmDB
extends java.lang.Object
implements Database

PalmDB is the abstract base class for all Palm build-in databases.

Version:
1.0
Author:
Bernd R. Fix
See Also:
Database

Field Summary
private  Database db
          reference to system created database object.
 
Fields inherited from interface brf.j2me.dynaworks.env.Database
ERR_APPEND, ERR_CREATE, ERR_DBFULL, ERR_DELETE, ERR_DEVICE, ERR_NODATA, ERR_NODB, ERR_OPEN, ERR_READ, ERR_WRITE, S_OK
 
Constructor Summary
PalmDB(java.lang.String name)
          Constructor for Palm build-in databases
 
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?
protected  PalmRec newRecord()
          Instanciate a new PalmRecord.
 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.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

db

private Database db
reference to system created database object.

Constructor Detail

PalmDB

public PalmDB(java.lang.String name)
Constructor for Palm build-in databases

Parameters:
name - String - identifier for the database
Method Detail

open

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

Specified by:
open in interface Database
Returns:
boolean - Database opened?

isOpen

public boolean isOpen()
Is the database opened?

Specified by:
isOpen in interface Database
Returns:
boolean - Is the database opened?

close

public void close()
Close the database.

Specified by:
close in interface Database

getErrorCode

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

Specified by:
getErrorCode in interface Database
Returns:
int - error code.

numberOfRecords

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

Specified by:
numberOfRecords in interface Database
Returns:
int - Number of records in the database (or -1 in case of failure).

addRecord

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

Specified by:
addRecord in interface Database
Parameters:
rec - Dataset - record to be added to the database.
Returns:
int - index of new record (or -1 in case of failure).
See Also:
Dataset

getRecord

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

Specified by:
getRecord in interface Database
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.

Specified by:
putRecord in interface Database
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.

Specified by:
deleteRecord in interface Database
Parameters:
idx - int - Index of the record to be deleted.
Returns:
boolean - delete successful?

newRecord

protected PalmRec newRecord()
Instanciate a new PalmRecord.

Returns:
PalmRec - newly allocated record.