Course Introduction - PowerPoint PPT Presentation

1 / 22
About This Presentation
Title:

Course Introduction

Description:

Only allow the manipulation of the MIDlet suite's own record stores ... An interface logically maintains a sequence of the record_Id's of the records in ... – PowerPoint PPT presentation

Number of Views:37
Avg rating:3.0/5.0
Slides: 23
Provided by: david2550
Category:

less

Transcript and Presenter's Notes

Title: Course Introduction


1
Course Introduction
  • J2ME Example

2
Introduction
  • The MIDP provides a mechanism for MIDlets to
    persistently store data and retrieve it later
  • This persistent storage mechanism, called the
    Record Management System (RMS), is modeled after
    a simple record-oriented database

3
Introduction
  • Only allow the manipulation of the MIDlet suites
    own record stores
  • Do not provide any mechanism for record sharing
    between MIDlets in different MIDlet suites
  • Record store names are case sensitive
  • up to 32 Unicode characters

4
Records
  • Records are arrays of bytes
  • Developers can use
  • DataInputStream
  • DataOutputStream
  • ByteArrayInputStream
  • ByteArrayOutputStream

5
Records
  • Records are uniquely identified within their
    record_Id (integer) as the primary key for the
    records
  • The first record created in a record store will
    have record_Id equal to 1, and each subsequent
    record_Id will monotonically increase by one

6
Records
7
Classes for Record Store
  • Package
  • javax.microedition.rms
  • Classes
  • RecordStore, RecordEnumeration
  • Interfaces
  • RecordComparator, RecordFilter, RecordListener

8
Management of Record Store
  • openRecordStore()
  • closeRecordStore()
  • listRecordStore()
  • deleteRecordStore()
  • getVersion(), getLastModified()

9
Record Manipulation
  • Basic manipulation
  • addRecord(), deleteRecord(), and getRecord(),
    setRecord()
  • Information retrieval
  • getNumRecords() , getRecordSize()
  • Information about a record
  • getSize(), getSizeAvailable()
  • Enumeration
  • getNextRecordID()

10
Basic Record Manipulation
  • addRecord
  • int addRecord(byte data, int offset, int
    numBytes)
  • Adds a new record to the record store
  • The recordId for this new record is returned

11
Basic Record Manipulation
  • deleteRecord
  • void deleteRecord(int recordId)
  • The record is deleted from the record store
  • getRecord
  • int getRecord(int recordId, byte buffer, int
    offset)
  • Returns the data stored in the given record

12
Basic Record Manipulation
  • setRecord
  • void setRecord(int recordId, byte newData, int
    offset, int nBytes)
  • Sets the data in the given record

13
ByteArrayOutputStream
14
ByteArrayInputStream
15
Monitoring Record Changing
  • RecordListener
  • recordAdded(recordStore, recordID)
  • recordChanged(recordStore, recordID)
  • recordDeleted(recordStore, recordID)
  • RecordStore
  • addRecordListener(listener)
  • removeRecordListener(listener)

16
Information retrieval
  • getNumRecords
  • Returns the number of records currently in the
    record store
  • getRecordSize
  • Returns the size (in bytes) of the MIDlet data
    available in the given record

17
Information about a record
  • getSize
  • Returns the amount of space, in bytes, that the
    record store occupies
  • getSizeAvailable
  • Returns the amount of additional room (in bytes)
    available for this record store to grow

18
Enumeration
  • getNextRecordID
  • Returns the record_Id of the next record to be
    added to the record store

19
Record Enumeration
  • An interface logically maintains a sequence of
    the record_Id's of the records in a record store
  • Methods
  • hasNextElement(), hasPreviousElement()
  • nextRecord(), nextRecordId()
  • previousRecord(), previousRecordId()

20
Record Enumeration
21
Record Comparator
  • An interface defining a comparator which compares
    two records to see if they match or what their
    relative sort order is
  • int compare(byte rec1, byte rec2)
  • Returns
  • PROCEEDS, FOLLOWS, EQUIVALENT

22
Example
Write a Comment
User Comments (0)
About PowerShow.com