1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package net.sf.jour.filter;
22
23 /***
24 * TODO Add docs
25 * Created on 04.12.2004
26 *
27 * Contributing Author(s):
28 *
29 * Misha Lifschitz <mishalifschitz at users.sourceforge.net> (Inital implementation)
30 * Vlad Skarzhevskyy <vlads at users.sourceforge.net> (Inital implementation)
31 *
32 * @author vlads
33 * @version $Revision: 1.6 $ ($Author: vlads $) $Date: 2004/12/08 19:37:26 $
34 */
35 public abstract class MatchFilter implements Filter {
36
37 public final static int MATCH_EXCLUDE = -1;
38 public final static int MATCH_NO = 0;
39 public final static int MATCH_YES = 1;
40 public final static int MATCH_EXACT = 2;
41
42 /***
43 * conditional compilation
44 * set to false to allow compiler to identify and eliminate
45 * unreachable code
46 */
47 protected static final boolean debug = false;
48
49 /***
50 * a name use for debuging complex lists.
51 */
52 public String name = "n/a";
53
54 public abstract int matchState(Object obj);
55
56 public int notMatch(int state) {
57 if (state >= MATCH_YES) {
58 return MATCH_EXCLUDE;
59 } else {
60 return MATCH_YES;
61 }
62 }
63
64 public int b2Match(boolean isMatch) {
65 if (isMatch) {
66 return MATCH_YES;
67 } else {
68 return MATCH_NO;
69 }
70 }
71
72 public boolean isMatch(int state) {
73 if (state > MATCH_NO) {
74 return true;
75 } else {
76 return false;
77 }
78 }
79
80 public abstract void debug();
81
82 public String match2String(int state) {
83 switch(state) {
84 case MATCH_EXCLUDE: return "MATCH_EXCLUDE";
85 case MATCH_NO: return "MATCH_NO";
86 case MATCH_YES: return "MATCH_YES";
87 case MATCH_EXACT: return "MATCH_EXACT";
88 default:
89 return "MATCH_??" + state;
90
91 }
92 }
93 }