jMobileCore toolkit

com.jmobilecore.dstore
Class Table

java.lang.Object
  extended by com.jmobilecore.dstore.Table

public abstract class Table
extends java.lang.Object

An abstract base class for record stores

Author:
Greg Gridin

Field Summary
static int INVALID_RECORD_ID
          The invalid record id
protected  boolean isOpen
          Indicates whether the RMStorage is open
 javax.microedition.rms.RecordComparator loadComparator
          The RecordComparator for data loading
 javax.microedition.rms.RecordFilter loadFilter
          The RecordFilter for data loading
 boolean loadKeepUpdated
          The keepUpdated flag for data loading
 javax.microedition.rms.RecordStore recordStore
          The RecordStore for storing table data
 RecordStructure structure
          The RecordStructure for the current Record
 
Constructor Summary
Table(java.lang.String name, boolean create)
          Creates new instance of Table class and opens data store
 
Method Summary
 int addRecord(Record rec)
          Adds new record to data store The record store should be open.
 boolean close()
          Closes the data store.
static boolean delete(java.lang.String name)
          Deletes the named record store.
 boolean deleteRecord(int id)
          Deletes data from the table The record store should be open.
 int getNumRecords()
          Returns the number of records currently in the record store.
 boolean load()
          Iterates through records in the record store
 boolean open(java.lang.String name, boolean create)
          Opens data store
abstract  boolean processRecord(byte[] data, int recId)
          Abstract method for processing record of current Table
 boolean setRecord(int id, Record rec)
          Sets data to the specified record The record store should be open.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INVALID_RECORD_ID

public static final int INVALID_RECORD_ID
The invalid record id

See Also:
Constant Field Values

isOpen

protected boolean isOpen
Indicates whether the RMStorage is open


loadComparator

public javax.microedition.rms.RecordComparator loadComparator
The RecordComparator for data loading


loadFilter

public javax.microedition.rms.RecordFilter loadFilter
The RecordFilter for data loading


loadKeepUpdated

public boolean loadKeepUpdated
The keepUpdated flag for data loading


recordStore

public javax.microedition.rms.RecordStore recordStore
The RecordStore for storing table data


structure

public RecordStructure structure
The RecordStructure for the current Record

Constructor Detail

Table

public Table(java.lang.String name,
             boolean create)
Creates new instance of Table class and opens data store

Parameters:
name - the MIDlet suite unique name for the table, not to exceed 32 characters
create - if true, the record store will be created if necessary.
Method Detail

addRecord

public int addRecord(Record rec)
Adds new record to data store The record store should be open. If record store is not open returns INVALID_RECORD_ID.

Parameters:
rec - The Record to be added
Returns:
the record id of added record. If record cannot be added returns INVALID_RECORD_ID.
See Also:
INVALID_RECORD_ID, open(java.lang.String, boolean), Record

close

public boolean close()
Closes the data store. This method does not destroy the Table class. Record structure and other table related information continue to be valid. You can reopen data storage by calling method open

Returns:
true if operation was successful, false otherwise
See Also:
open(String, boolean)

delete

public static boolean delete(java.lang.String name)
Deletes the named record store.

Parameters:
name - Name the MIDlet suite unique name for the table, not to exceed 32 characters
Returns:
true if operation was successful, false otherwise

deleteRecord

public boolean deleteRecord(int id)
Deletes data from the table The record store should be open. If record store is not open returns false.

Parameters:
id - The id of the record to use in this operation.
Returns:
true if deletion was successful, false otherwise
See Also:
Record

getNumRecords

public int getNumRecords()
Returns the number of records currently in the record store. The record store should be open. If record store is not open returns -1.

See Also:
isOpen, open(java.lang.String, boolean)

load

public boolean load()
Iterates through records in the record store

Returns:
true if operation was successful, false otherwise

open

public boolean open(java.lang.String name,
                    boolean create)
Opens data store

Parameters:
name - the MIDlet suite unique name for the table, not to exceed 32 characters
create - if true, the record store will be created if necessary.
Returns:
true if operation was successful, false otherwise

processRecord

public abstract boolean processRecord(byte[] data,
                                      int recId)
Abstract method for processing record of current Table

Parameters:
data - The binary data representing record used in this operation
recId - The id of the record to use in this operation.
Returns:
true if record processing should continue, false if record processing should be stopped

setRecord

public boolean setRecord(int id,
                         Record rec)
Sets data to the specified record The record store should be open. If record store is not open returns false.

Parameters:
id - The id of the record to use in this operation.
rec - The Record to be set
Returns:
true if update was successful, false otherwise
See Also:
addRecord(Record), Record

jMobileCore toolkit