01: package org.swingml.treetablebrowser.ext;
02:
03: import java.util.*;
04:
05: /**
06: * @author dpitt
07: *
08: * To change this generated comment edit the template variable "typecomment":
09: * Window>Preferences>Java>Templates.
10: * To enable and disable the creation of type comments go to
11: * Window>Preferences>Java>Code Generation.
12: */
13: public class Pattern {
14: private String key = null;
15: List list = new ArrayList();
16:
17: public void add(String value) {
18: if (list.indexOf(value) < 0) {
19: list.add(value);
20: }
21: }
22:
23: public boolean equals(String value) {
24: for (int i = 0; i < list.size(); i++) {
25: String ele = (String) list.get(i);
26: if (ele.equalsIgnoreCase(value)) {
27: return true;
28: }
29: }
30: return false;
31: }
32:
33: /**
34: * Returns the key.
35: * @return String
36: */
37: public String getKey() {
38: return key;
39: }
40:
41: public boolean isEmpty() {
42: return list.isEmpty();
43: }
44:
45: public boolean matches(String value) {
46: Iterator itr = list.iterator();
47: while (itr.hasNext()) {
48: String pattern = (String) itr.next();
49: if (value.toLowerCase().indexOf(pattern.toLowerCase()) == 0) {
50: return true;
51: }
52: }
53: return false;
54: }
55:
56: public void remove(String value) {
57: list.remove(value);
58: }
59:
60: /**
61: * Sets the key.
62: * @param key The key to set
63: */
64: public void setKey(String key) {
65: this.key = key;
66: }
67: }
|