com.sun.kjava
Class Database

java.lang.Object
  |
  +--com.sun.kjava.Database

public class Database
extends java.lang.Object

This class serves as an interface to the PalmOS database manager. It allows the user to create and access PalmOS databases from KJava.


Field Summary
static int ENDOFDATABASE
          End of database (last record indicator).
static int READONLY
          Read-only mode.
static int READWRITE
          Read and write mode.
static int WRITEONLY
          Write-only mode.
 
Constructor Summary
Database(int typeID, int creatorID, int mode)
          Open a database.
 
Method Summary
 boolean addRecord(byte[] data)
          Add a new record to the end of the database.
 void close()
          Close the current database.
static boolean create(int cardNo, java.lang.String name, int creatorID, int typeID, boolean resDB)
          Create a new database.
 boolean deleteRecord(int recordNumber)
          Delete an existing record.
 int getNumberOfRecords()
          Get the number of records in the database.
 byte[] getRecord(int recordNumber)
          Read a database record into a Java byte array object.
 boolean isOpen()
          Check if the database is open.
 int readRecordToBuffer(int recordNumber, int readOffset, int length, byte[] buffer, int writeOffset)
          Read record to a pre-allocated buffer instead of allocating a new bytearray each time.
 boolean setRecord(int recordNumber, byte[] data)
          Set the contents of a PalmOS database record.
 int writeRecordFromBuffer(int recordNumber, int writeOffset, int length, byte[] buffer, int readOffset)
          Set the contents of a database record.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

READONLY

public static final int READONLY
Read-only mode.

WRITEONLY

public static final int WRITEONLY
Write-only mode.

READWRITE

public static final int READWRITE
Read and write mode.

ENDOFDATABASE

public static final int ENDOFDATABASE
End of database (last record indicator).
Constructor Detail

Database

public Database(int typeID,
                int creatorID,
                int mode)
Open a database.
Method Detail

create

public static boolean create(int cardNo,
                             java.lang.String name,
                             int creatorID,
                             int typeID,
                             boolean resDB)
Create a new database.

isOpen

public boolean isOpen()
Check if the database is open.

getNumberOfRecords

public int getNumberOfRecords()
Get the number of records in the database.

getRecord

public byte[] getRecord(int recordNumber)
Read a database record into a Java byte array object. Remember that PalmOS database record numbers start from 0.

setRecord

public boolean setRecord(int recordNumber,
                         byte[] data)
Set the contents of a PalmOS database record.

addRecord

public boolean addRecord(byte[] data)
Add a new record to the end of the database.

deleteRecord

public boolean deleteRecord(int recordNumber)
Delete an existing record.

readRecordToBuffer

public int readRecordToBuffer(int recordNumber,
                              int readOffset,
                              int length,
                              byte[] buffer,
                              int writeOffset)
Read record to a pre-allocated buffer instead of allocating a new bytearray each time. Also allow a record to be read partially if necessary. Currently unimplemented.

writeRecordFromBuffer

public int writeRecordFromBuffer(int recordNumber,
                                 int writeOffset,
                                 int length,
                                 byte[] buffer,
                                 int readOffset)
Set the contents of a database record. Allows more complex data manipulation than setRecord. Currently unimplemented.

close

public void close()
Close the current database.