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