📄 simplefilter.java
字号:
/* * Copyright (c) 2000-2001 Sun Microsystems, Inc. All Rights Reserved. */package examples.addressbook;import java.lang.*;import java.io.*;import java.util.*;import javax.microedition.rms.*;/** * This class implements the RecordFilter interface. * It works on the records created by SimpleRecord. * It filters on first name and/or last name. */public class SimpleFilter implements RecordFilter { // first and last names on which to filter private String first; private String last; /** * Public constructor: stores the first and last * names on which to filter. Stores first/last * names as lower case so that filters are * are case-insensitive. */ public SimpleFilter(String f, String l) { first = f.toLowerCase(); last = l.toLowerCase(); } /** * Takes a record, (r), and checks to see if it matches * the first and last name set in our constructor. * * Extracts the first and last names from the record, * converts them to lower case, then compares them * with the values extracted from the record. * * return true if record matches, false otherwise */ public boolean matches(byte[] r) { String f = SimpleRecord.getFirstName(r).toLowerCase(); String l = SimpleRecord.getLastName(r).toLowerCase(); return f.startsWith(first) && l.startsWith(last); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -