listing16-06_recordstorereader.java_ok
来自「着几乎所有智能机厂商都将有自己配套的App Store,甚至并非智能手机制造商的」· JAVA_OK 代码 · 共 52 行
JAVA_OK
52 行
// Listing 16-6. Filtering and Sorting a Record Store Simultaneously
import javax.microedition.rms.*;
import de.enough.polish.util.ArrayList;
public class RecordStoreReader {
private final ArrayList list;
public RecordStoreReader( Object condition )
throws RecordStoreException
{
// open record store:
RecordStore store = RecordStore.openRecordStore( "store", false );
// enumerate the record sets the fastest possible way:
RecordEnumeration enumeration =
store.enumerateRecords( null, null, false );
ArrayList recordList = new ArrayList( enumeration.numRecords() );
while ( enumeration.hasNextElement() ) {
MyRecordData data = new MyRecordData( enumeration.nextRecord() );
if ( !data.conditionFulfilled( condition ) ) {
continue;
}
boolean notInserted = true;
for ( int i = recordList.size(); --i >= 0; ) {
MyRecordData compare = (MyRecordData) recordList.get( i );
if ( data.compare( compare ) != RecordComparator.PRECEDES ) {
recordList.add( i + 1, data );
notInserted = false;
break;
}
}
if ( notInserted ) {
recordList.add( 0, data );
}
}
store.closeRecordStore();
this.list = recordList;
}
public ArrayList getRecords() {
return this.list;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?