Name
RecordFilter
Synopsis
This interface selects which RecordStore
records should
be included in a RecordEnumeration
. It consists
of a single method, matches()
, which examines the
contents of a record and returns true
if the record
should be included, or false
if it should not.
A typical implementation of this method wraps the incoming record with a
ByteArrayInputStream
and a DataInputStream
so that the contents of the record can be accessed as a set of fields.
For example, to construct a filter that would include only records whose
first field (assumed to be a String
) starts with the
letter S
, first create a DataInputStream
from the candidate:
DataInputStream dis = new DataInputStream(new ByteArrayInputStream(candidate));
Then, extract the field to be compared using the
DataInputStream
readUTF()
method
and test its first character:
return dis.readUTF().startsWith("S");
public interface RecordFilter { // Public Instance Methods public abstract boolean matches(byte[] candidate); }
Passed To
RecordStore.enumerateRecords()
Get J2ME in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.