KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > columba > core > filter > Filter


1 // The contents of this file are subject to the Mozilla Public License Version 1.1
2
// (the "License"); you may not use this file except in compliance with the
3
// License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
4
//
5
// Software distributed under the License is distributed on an "AS IS" basis,
6
// WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
7
// for the specific language governing rights and
8
// limitations under the License.
9
//
10
// The Original Code is "The Columba Project"
11
//
12
// The Initial Developers of the Original Code are Frederik Dietz and Timo Stich.
13
// Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
14
//
15
// All Rights Reserved.
16
//$Log: Filter.java,v $
17
//Revision 1.2 2006/06/20 19:49:29 fdietz
18
//[intern]added paging support in api and mail search provider backend.
19
//
20
//Revision 1.1 2006/06/10 12:59:03 fdietz
21
//[intern]initial commit for new sourcecode structure
22
//
23
//Revision 1.3 2005/09/17 12:18:18 fdietz
24
//[bug] filter helper didn't work (Utilities-> create filter on message)
25
//
26
//Revision 1.2 2005/01/16 22:52:43 fdietz
27
//[intern]configurationn cleanup, removed obsolete classes, replaced usage of XmlElement with Item wrapper classes, added constants instead of direct string usage
28
//
29
//Revision 1.1 2004/12/23 10:41:49 fdietz
30
//[feature]added new filter toolbar, using vFolder search capability instead of table-model, moved Ifolder, foldercommand, foldercommandreference, and all filter/filteractions code in core package
31
//
32
package org.columba.core.filter;
33
34 import org.columba.core.config.DefaultItem;
35 import org.columba.core.xml.XmlElement;
36
37 /**
38  * Wrapper for the filter xml configuration, which makes code easier to read in
39  * comparison to using the XmlElement stuff.
40  *
41  * @author frd
42  */

43
44 // example configuration (tree.xml):
45
//
46
// <filter description="gnome" enabled="true">
47
// <rules condition="matchany">
48
// <criteria criteria="contains" headerfield="To or Cc" pattern="gnome" type="To
49
// or Cc"></criteria>
50
// </rules>
51
// <actionlist>
52
// <action uid="120" type="Move Message"></action>
53
// </actionlist>
54
// </filter>
55
//
56
public class Filter extends DefaultItem implements IFilter {
57
58     private static final String JavaDoc DESCRIPTION = "description";
59
60     private static final String JavaDoc ENABLED = "enabled";
61
62     private static final String JavaDoc RULES = "rules";
63
64     private static final String JavaDoc ACTIONLIST = "actionlist";
65
66     private static final String JavaDoc FILTER = "filter";
67
68     private Filter() {
69         super(new XmlElement(Filter.FILTER));
70     }
71
72     /**
73      *
74      * Constructor for Filter
75      *
76      * XmlElement should be "filter" in this case
77      *
78      * @see org.columba.core.config.DefaultItem#DefaultItem(XmlElement)
79      */

80     public Filter(XmlElement root) {
81         super(root);
82     }
83
84     
85     /* (non-Javadoc)
86    * @see org.columba.core.filter.IFilter#getFilterActionList()
87    */

88     public IFilterActionList getFilterActionList() {
89         XmlElement element = getRoot().getElement(Filter.ACTIONLIST);
90         
91         return new FilterActionList(element);
92
93     }
94
95     /* (non-Javadoc)
96    * @see org.columba.core.filter.IFilter#getFilterRule()
97    */

98     public IFilterRule getFilterRule() {
99         XmlElement element = getRoot().getElement(Filter.RULES);
100         
101
102         return new FilterRule(element);
103     }
104
105     /* (non-Javadoc)
106    * @see org.columba.core.filter.IFilter#getEnabled()
107    */

108     public boolean getEnabled() {
109         return getBooleanWithDefault(Filter.ENABLED, true);
110     }
111
112     /* (non-Javadoc)
113    * @see org.columba.core.filter.IFilter#setEnabled(boolean)
114    */

115     public void setEnabled(boolean bool) {
116         setBoolean(Filter.ENABLED, bool);
117     }
118
119     /* (non-Javadoc)
120    * @see org.columba.core.filter.IFilter#setName(java.lang.String)
121    */

122     public void setName(String JavaDoc s) {
123         setString(Filter.DESCRIPTION, s);
124     }
125
126     /* (non-Javadoc)
127    * @see org.columba.core.filter.IFilter#getName()
128    */

129     public String JavaDoc getName() {
130         return get(Filter.DESCRIPTION);
131     }
132
133     /* (non-Javadoc)
134    * @see org.columba.core.filter.IFilter#clone()
135    */

136     public Object JavaDoc clone() {
137         return super.clone();
138     }
139
140     /* (non-Javadoc)
141    * @see org.columba.core.filter.IFilter#toString()
142    */

143     public String JavaDoc toString() {
144         StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
145         sb.append("Filter[name=");
146         sb.append(getName());
147         sb.append(", enabled=");
148         sb.append(getEnabled());
149         sb.append("]");
150
151         return sb.toString();
152     }
153 }
Popular Tags