store
Class StorableObject

java.lang.Object
  |
  +--store.StorableObject

public class StorableObject
extends java.lang.Object

A StorableObject contains a reference to an object that implements the Storable interface, and also contains the name of the record store and specific record id where this object is kept.


Constructor Summary
StorableObject(java.lang.String s, int id, Storable data)
          Create a new StorableObject.
 
Method Summary
 int getRecordID()
          Get the record id associated with the user data object.
 java.lang.String getStoreName()
          Get the record store name associated with the user data object.
 Storable getUserData()
          Get the user data object.
 void readUserDataObject()
          Read an array of bytes from the record store, then use the methods provided by a Storable object to update the fields of the object.
 void writeUserDataObject()
          Write the fields of a Storable object into an array of bytes, then write that array of bytes into the RecordStore.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StorableObject

public StorableObject(java.lang.String s,
                      int id,
                      Storable data)
Create a new StorableObject.

Parameters:
s - the String name of the RecordStore where the user data is kept
id - the record id for this user data
data - the actual user data object kept in the record store
Method Detail

getStoreName

public java.lang.String getStoreName()
Get the record store name associated with the user data object.

Returns:
the name of the record store where this item is kept

getRecordID

public int getRecordID()
Get the record id associated with the user data object.

Returns:
the record id for this object. 0 if not written into the record store anywhere yet.

getUserData

public Storable getUserData()
Get the user data object.

Returns:
the user data object

readUserDataObject

public void readUserDataObject()
                        throws javax.microedition.rms.RecordStoreException,
                               java.io.IOException
Read an array of bytes from the record store, then use the methods provided by a Storable object to update the fields of the object. Note that it is the responsibility of the caller to only read the correct type of object from the RecordStore. If the record has no data, this method returns without changing the object (and without throwing an exception).

Throws:
javax.microedition.rms.RecordStoreException - if anything bad happens while getting the record
java.io.IOException - if anything bad happens while reading the record data into the object

writeUserDataObject

public void writeUserDataObject()
                         throws javax.microedition.rms.RecordStoreException,
                                java.io.IOException
Write the fields of a Storable object into an array of bytes, then write that array of bytes into the RecordStore.

Throws:
javax.microedition.rms.RecordStoreException - if anything bad happens while writing the record
java.io.IOException - if anything bad happens while writing the record data into the byte array