Session11 J2ME Record Management System

1,768
-1

Published on

Session11 J2ME Record Management System

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,768
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
44
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Session11 J2ME Record Management System

  1. 1. Outline-session 11 (20-April-2009) <ul><li>>> J2ME Record Management System </li></ul><ul><li>-Notification of Changes with Record Listener </li></ul><ul><li>-Exception Handling </li></ul>
  2. 2. Record Listener <ul><li>>>Record Listener is a interface in javax.microedition.rms package. </li></ul><ul><li>>> we have to add the Record Listener implemented class with Record store Class. </li></ul><ul><li>>> Record listener has the three methods are recordAdded(),recordChanged(),recordDeleted() </li></ul><ul><li>>>All three methods will be called ,if any changes occurred in record of the record store. </li></ul>
  3. 3. Record Listener API RecordListener Interface in javax.microedition.rms.RecordListener Method Description void recordAdded(RecordStore recordStore, int recordId) Called when record is added Void recordChanged(RecordStore rs,int recordid) Called when record is Updated Void recordDeleted(RecordStore rs,.int recordid) Called when record is deleted.
  4. 4. RecordListener Interface Implementation <ul><li>Class RLAction implements RecordListenert </li></ul><ul><li>{ </li></ul><ul><li>public void recordAdded(RecordStore rs,int recordd) </li></ul><ul><li>{ </li></ul><ul><li>System.out.println(“Record inserted”); </li></ul><ul><li>} </li></ul><ul><li>public void recordChanged(RecordStore rs, int recordid) </li></ul><ul><li>{ </li></ul><ul><li>System.out.println(“Record Chanage”); </li></ul><ul><li>} </li></ul><ul><li>public void recordDeleted(RecordStore rs, inr recordid) </li></ul><ul><li>{ </li></ul><ul><li>System,.out.println(“Record deleted”); </li></ul><ul><li>} </li></ul><ul><li>} </li></ul><ul><li>RLAction rl =new RLAction()); RescordStore rsss=new RecordStore(“test”,true); </li></ul><ul><li>rss.addRecordListener(rl); </li></ul>
  5. 5. Sample program <ul><li>>>RMSListener.java </li></ul>
  6. 6. Exception Handling <ul><li>>>There are five exception that are specific to the RMS. </li></ul><ul><li>>>All Exception are inherited from java.lanag.Throwable class. </li></ul><ul><li>>>Exception are </li></ul><ul><ul><li>InvalidRecordIDException </li></ul></ul><ul><ul><li>RecordStoreException </li></ul></ul><ul><ul><li>RecordStoreFullException </li></ul></ul><ul><ul><li>RecordStoreNotFoundException </li></ul></ul><ul><ul><li>RecordStoreNotOpenException </li></ul></ul>
  7. 7. Exception Handling <ul><li>>> InvalidRecordIDException </li></ul><ul><li>-- Used to indicate an invalid record number </li></ul><ul><li>-- if RecordStore.getRecord(int) is called with a record that does not exist in the record store, this exception will be thrown </li></ul><ul><li>>>public InvalidRecordIDException(String message) </li></ul><ul><li>>>public InvalidRecordIDException() </li></ul>
  8. 8. Exception Handling <ul><li>>> RecordStoreException </li></ul><ul><li>-- A general exception indicating an error with the record store. </li></ul><ul><li>>> public RecordStoreException() </li></ul><ul><li>>>public RecordStoreException(String message) </li></ul>
  9. 9. Exception Handling <ul><li>>> RecordStoreFullException </li></ul><ul><li>-- Signals the record store is full </li></ul><ul><li>-- if RecordStore.add Record(byte[], int, int) is called to add a new record, this exception will be thrown if the record store has reached its maximum capacity </li></ul><ul><li>public RecordStoreFullException() </li></ul><ul><li>public RecordStoreFullException(String message) </li></ul>
  10. 10. Exception Handling <ul><li>>> RecordStoreNotFoundException </li></ul><ul><li>-- Indicates the record store name does not exist </li></ul><ul><li>-- calling RecordStore.deleteRecordStore(String) with an invalid record store name will result in this exception being thrown </li></ul><ul><li>>> public RecordStoreNotFoundException() </li></ul><ul><li>>>public RecordStoreNotFoundException(String message) </li></ul>
  11. 11. Exception Handling <ul><li>>> RecordStoreNotOpenException </li></ul><ul><li>-- Used to indicate that the requested record store is not open. </li></ul><ul><li>-- For example, if RecordStore.getNumRecords() is called prior to opening the record store, this exception will be thrown. </li></ul><ul><li>>>public RecordStoreNotOpenException() </li></ul><ul><li>>>public RecordStoreNotFoundOpen(String message) </li></ul>

×