01: /***
02: * jwma Java WebMail
03: * Copyright (c) 2000-2003 jwma team
04: *
05: * jwma is free software; you can distribute and use this source
06: * under the terms of the BSD-style license received along with
07: * the distribution.
08: ***/package dtw.webmail.util;
09:
10: import dtw.webmail.model.JwmaContact;
11: import org.apache.log4j.Logger;
12:
13: public class LastnameStartsWithFilter implements ContactFilter {
14:
15: private static Logger log = Logger
16: .getLogger(LastnameStartsWithFilter.class);
17: private String m_Startswith = "";
18:
19: public LastnameStartsWithFilter(String start) {
20: m_Startswith = start;
21: }//constructor
22:
23: public boolean isFiltered(JwmaContact contact) {
24: //log.debug("isFiltered()::"+contact.getLastname()+"::"+m_Startswith+"::"+
25: //(!contact.getLastname().startsWith(m_Startswith))
26: //);
27: if (m_Startswith.length() == 0) {
28: return false;
29: } else {
30: return !contact.getLastname().startsWith(m_Startswith);
31: }
32: }//isFiltered
33:
34: public boolean isAllowed(JwmaContact contact) {
35: //log.debug("isAllowed()::"+contact.getLastname()+"::"+m_Startswith+"::"+
36: //(contact.getLastname().startsWith(m_Startswith))
37: //);
38: if (m_Startswith.length() == 0) {
39: return true;
40: } else {
41: return contact.getLastname().startsWith(m_Startswith);
42: }
43: }//isAllowed
44:
45: public String getStartsWith() {
46: return m_Startswith;
47: }//getStartsWith
48:
49: public void setStartsWith(String startswith) {
50: m_Startswith = startswith;
51: }//setStartsWith
52:
53: public String toString() {
54: return m_Startswith;
55: }//toString
56:
57: }//LastnameStartsWithFilter
|