Record Management System (III)

24 April 2008

In 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.

del.icio.us:Record Management System (III)  digg:Record Management System (III)  spurl:Record Management System (III)  wists:Record Management System (III)  simpy:Record Management System (III)  newsvine:Record Management System (III)  blinklist:Record Management System (III)  furl:Record Management System (III)  reddit:Record Management System (III)  fark:Record Management System (III)  blogmarks:Record Management System (III)  Y!:Record Management System (III)  smarking:Record Management System (III)  magnolia:Record Management System (III)  segnalo:Record Management System (III)  gifttagging:Record Management System (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)

Leave a Reply