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()
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access