Talk:Record sorting in RMS
Article Review by Larry101
(20090928)
The Record Management System (RMS) allows persistent data storage in Java ME, even on devices that don’t support JSR-75. This article demonstrates how we can retrieve the contents of a RecordStore in sorted order. The article primarily consists of a code example, showing a sample implementation of the RecordComparator interface. By simply passing an implementation of this interface of a RecordEnumeration object, the contents can be returned in sorted order.
The Record Management System (RMS) allows persistent data storage in Java ME, even on devices that don’t support JSR-75. This article demonstrates how we can retrieve the contents of a RecordStore in sorted order. The article primarily consists of a code example, showing a sample implementation of the RecordComparator interface. By simply passing an implementation of this interface of a RecordEnumeration object, the contents can be returned in sorted order.
For those familiar with how sorting works in Java SE, this will be a very familiar concept. The code example is kept nice and simple. It shows both how to instantiate a sorted RecordEnumeration and how to implement the RecordComparator interface (through the compare method). The entire process is also shown in a complete code example, showing the process from start to finish.
One relatively minor criticism I have of this article is that it does not show how the compare method should be implemented differently if the programmer desires the records to be sorted in descending order as opposed to ascending order. This is a simple matter of swapping the PRECEDES and FOLLOWS return values.

