Record Management System (III)
24 April 2008In this post, I will continue writing about RMS - but more specifically relavent to codding.
Often you want to compare records and determine relative sort order. For that, the MIDlet implements the RecordComparator interface and defines a compare (byte[] rec1, byte[] rec2) method, which is use to compare two candidate records. Its return value of this method must indicate the ordering of the two records.
Int compare (byte[] b1, byte[] b2) { String s1 = new String(b1); String s2 = new String(b2); If (s1.compareTo(s2) > 0) Return RecordComparator.FOLLOWS; Else if (s1.compareTo(s2) == 0) Return RecordComparator.EQUIVALENT; Else Return RecordComparator.PRECEDES; }
Enumerating through records is also possible using RecordEnumeration as shown in the following snippet.
RecordEnumeration re = rs.enumerateRecords(null, null, false); If (re.hasNextElement()) Byte nextRec[] = re.nextRecord();
Play with RMS and explore more.
Related Posts:
- Record Management System (II)
- Record Management System (I)
- RecordStore with examples - II
- RecordStore with examples - I
- RecordStore with examples - III
- ANT’s best practices - IV
- in.use file
- SVN (Trunk/Branch/Tag) - II
- Java performance Issues (III) - Garbage collection
- Deploying MIDlets onto Mobile Devices (III)
Top Of Page | Trackback
If you found this page useful, consider linking to it. Simply copy and paste the code below into your web site.
It will look like this: Record Management System (III)