io
Class RMSHandler

java.lang.Object
  extended by io.RMSHandler

public class RMSHandler
extends java.lang.Object

A class to read and store variables permanently on the mobile using the Record Management System ( RMS ). There are two record stores: One is used to save the properties (settings) of the Application. The other one saves binary data like the mapping-file of items to units (=mapsource[1]) or the graphical representation of the items (=image[0]).

Author:
Peter Hlavac

Field Summary
static int MAP_IMAGE
           
static int MAP_SOURCE
           
 
Constructor Summary
RMSHandler()
           
 
Method Summary
 java.util.Vector getRecords()
          Enumerates through Record Store and store records in a Vector as String elements (e.g.: "map=gztan.png")
 int getResourceSize(int i)
          Returns the size of a resources
 boolean isEmpty()
          Checks if a Record Store (RS) exists on device
 byte[] loadResource(int i)
          Loads a resources in a byte array from the RMS
 java.lang.String loadResourceToString(int i)
          Loads a resources in a String from the RMS
 void storeRecords(java.util.Vector records)
          Stores the elements of a given vector to a record store.
 void storeResources(java.util.Vector records)
          Stores a Vector of binary resources (byte arrays) to the RMS
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAP_IMAGE

public static final int MAP_IMAGE
See Also:
Constant Field Values

MAP_SOURCE

public static final int MAP_SOURCE
See Also:
Constant Field Values
Constructor Detail

RMSHandler

public RMSHandler()
Method Detail

storeResources

public void storeResources(java.util.Vector records)
                    throws javax.microedition.rms.RecordStoreException
Stores a Vector of binary resources (byte arrays) to the RMS

Parameters:
records - the vector of byte arrays to store
Throws:
javax.microedition.rms.RecordStoreException - If a Recordstore can not be created or opened

loadResource

public byte[] loadResource(int i)
                    throws javax.microedition.rms.RecordStoreException
Loads a resources in a byte array from the RMS

Parameters:
i - the index of the resource to load
Returns:
the resource as a byte array
Throws:
javax.microedition.rms.RecordStoreException - thrown if a Recordstore can not be created or opened

getResourceSize

public int getResourceSize(int i)
                    throws javax.microedition.rms.RecordStoreException
Returns the size of a resources

Parameters:
i - the index of the resource
Returns:
the size in bytes of the resource
Throws:
javax.microedition.rms.RecordStoreException - thrown if a Recordstore can not be created or opened

loadResourceToString

public java.lang.String loadResourceToString(int i)
                                      throws javax.microedition.rms.RecordStoreException
Loads a resources in a String from the RMS

Parameters:
i - the index of the resource to load
Returns:
the resource converted to a string
Throws:
javax.microedition.rms.RecordStoreException - thrown if a Recordstore can not be created or opened

isEmpty

public boolean isEmpty()
Checks if a Record Store (RS) exists on device

Returns:
true if RS is on device, else false

getRecords

public java.util.Vector getRecords()
                            throws javax.microedition.rms.RecordStoreException
Enumerates through Record Store and store records in a Vector as String elements (e.g.: "map=gztan.png")

Returns:
a Vector with record elements converted to Strings
Throws:
javax.microedition.rms.RecordStoreException - thrown if access to record store is not possible

storeRecords

public void storeRecords(java.util.Vector records)
                  throws javax.microedition.rms.RecordStoreNotOpenException,
                         javax.microedition.rms.RecordStoreException
Stores the elements of a given vector to a record store. Overwrites old values in deleting the RS first.

Parameters:
records - the records to store
Throws:
javax.microedition.rms.RecordStoreNotOpenException - thrown if RS is not open
javax.microedition.rms.RecordStoreException - thrown if RS is not accessable