org.garret.serme.rms
Class RmsStorage

java.lang.Object
  extended byorg.garret.serme.rms.RmsStorage
All Implemented Interfaces:
IStorage

public class RmsStorage
extends java.lang.Object
implements IStorage

Storage implementation on top of javax.microedition.rms package. This implementation should be used for convenient fetching/storing persistent data in J2ME application.


Constructor Summary
RmsStorage(java.lang.String name)
          Storage constructor
 
Method Summary
 void close()
          Close database
 boolean create()
          Open existed or create new database
 java.util.Enumeration enumerateObjects()
          Get enumeration of all live persistent objects in the database.
 java.lang.Object getRoot()
          Get root object.
 boolean open()
          Open existed database.
 boolean remove()
          Remove database.
 void remove(java.lang.Object obj)
          Remove object from the storage.
 void setRoot(java.lang.Object root)
          Set new root object.
 void store(java.lang.Object obj)
          Store object in the database.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RmsStorage

public RmsStorage(java.lang.String name)
Storage constructor

Parameters:
name - name of the storage (passed to javax.microedition.rms.RecordStore.openStore)
Method Detail

close

public void close()
Description copied from interface: IStorage
Close database

Specified by:
close in interface IStorage

create

public boolean create()
Description copied from interface: IStorage
Open existed or create new database

Specified by:
create in interface IStorage
Returns:
true if database was successfully opened, false otherwise

enumerateObjects

public java.util.Enumeration enumerateObjects()
Description copied from interface: IStorage
Get enumeration of all live persistent objects in the database. Objects are returned in arbitrary order.

Specified by:
enumerateObjects in interface IStorage
Returns:
enumeration of all persistent objects in the database

getRoot

public java.lang.Object getRoot()
Description copied from interface: IStorage
Get root object. Database can have only one root object. When database is just created, there are not root object at all and this method returns null

Specified by:
getRoot in interface IStorage

open

public boolean open()
Description copied from interface: IStorage
Open existed database. Method will fail if database doesn't exist.

Specified by:
open in interface IStorage
Returns:
true if database was successfully opened, false otherwise

remove

public boolean remove()
Description copied from interface: IStorage
Remove database. This method can be invoked only for not opened database.

Specified by:
remove in interface IStorage
Returns:
true if database was successfully deleted, false otherwise

remove

public void remove(java.lang.Object obj)
Description copied from interface: IStorage
Remove object from the storage. All references to the removed object will be replaced with null when database will be opened next time.

Specified by:
remove in interface IStorage

setRoot

public void setRoot(java.lang.Object root)
Description copied from interface: IStorage
Set new root object. Old root object is not removed from the database.

Specified by:
setRoot in interface IStorage
Parameters:
root - new root object. If it is not yet persistent (has no assigned OID), it is automatically made persistent and stored in the database.

store

public void store(java.lang.Object obj)
Description copied from interface: IStorage
Store object in the database. If object is not yet persistent (not assigned OID), then it is made persistent. When object is stored all transient objects (objets without assigned OID) referenced from this object are recursively stored in the database. But referenced persistent objects are not recursively stored. So you should exeplicitly invoke store method for each modified persistent object.

Specified by:
store in interface IStorage