KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > nemesis > forum > MessageFilter


1 /*
2  * NEMESIS-FORUM.
3  * Copyright (C) 2002 David Laurent(lithium2@free.fr). All rights reserved.
4  *
5  * Copyright (c) 2000 The Apache Software Foundation. All rights reserved.
6  *
7  * Copyright (C) 2001 Yasna.com. All rights reserved.
8  *
9  * Copyright (C) 2000 CoolServlets.com. All rights reserved.
10  *
11  * NEMESIS-FORUM. is free software; you can redistribute it and/or
12  * modify it under the terms of the Apache Software License, Version 1.1,
13  * or (at your option) any later version.
14  *
15  * NEMESIS-FORUM core framework, NEMESIS-FORUM backoffice, NEMESIS-FORUM frontoffice
16  * application are parts of NEMESIS-FORUM and are distributed under
17  * same terms of licence.
18  *
19  *
20  * NEMESIS-FORUM includes software developed by the Apache Software Foundation (http://www.apache.org/)
21  * and software developed by CoolServlets.com (http://www.coolservlets.com).
22  * and software developed by Yasna.com (http://www.yasna.com).
23  *
24  */

25 package org.nemesis.forum;
26
27 import java.io.Serializable JavaDoc;
28 import java.util.Date JavaDoc;
29 import java.util.Enumeration JavaDoc;
30 import java.util.Iterator JavaDoc;
31 import java.util.Map JavaDoc;
32
33 import org.nemesis.forum.exception.UnauthorizedException;
34
35 /**
36  * A filter acts as a layer between a forum skin and a real ForumMessage
37  * object. It provides extended functionality by dynamically reformatting
38  * ForumMessage contents.
39  * <p>
40  * An unlimited number of ForumMessageFilters can be specified to be applied
41  * per Forum. Object-oriented designers will recognize this class as a
42  * Decorator for ForumMessages.
43  *
44  * @see ForumMessage
45  */

46 public abstract class MessageFilter implements Message, Serializable JavaDoc {
47
48     /**
49      * The underlying message the filter is applied to.
50      */

51     protected Message message = null;
52
53     /**
54      * Creates a new filter not associated with a message. This is
55      * generally only useful for defining a template filter that other
56      * fitlers will be cloned from.
57      */

58     public MessageFilter() {
59         //do nothing;
60
}
61
62     /**
63      * Creates a new filter wrapped around the specified message.
64      *
65      * @param message the ForumMessage to wrap the new filter around.
66      */

67     public MessageFilter(Message message) {
68         this.message = message;
69     }
70
71     /**
72      * Clones a new filter that will have the same properties and that
73      * will wrap around the specified message.
74      *
75      * @param message the ForumMessage to wrap the new filter around.
76      */

77     public abstract MessageFilter clone(Message message);
78
79     /**
80      * Returns the name of the filter.
81      *
82      * @return the name of the filter.
83      */

84     public abstract String JavaDoc getName();
85
86     /**
87      * Returns a description of the filter. The description of the filter should
88      * include information about what the filter does, as well as any critical
89      * usage notes.
90      *
91      * @return the description of the filter.
92      */

93     public abstract String JavaDoc getDescription();
94
95     /**
96      * Returns a URL that has documentation about the filter. By default, the
97      * method returns null, which means that no documentation is available.<p>
98      *
99      * Documentation should include installation as well as usage guidlines.
100      *
101      * @return a URL with documentation about the filter, or null if no
102      * documentation is available.
103      */

104     public String JavaDoc getDocumentationURL() {
105         return null;
106     }
107
108     
109     /**
110      * Returns the value of a property of the filter.
111      *
112      * @param name the name of the property.
113      * @return the value of the property.
114      */

115     public abstract String JavaDoc getFilterProperty(String JavaDoc name);
116
117     /**
118      * Returns the description of a property of the filter.
119      *
120      * @param name the name of the property.
121      * @return the description of the property.
122      */

123     public abstract String JavaDoc getFilterPropertyDescription(String JavaDoc name);
124
125     /**
126      * Returns an enumeration of the property names of the filter.
127      *
128      * @return an enumeration of the property names of the filter.
129      */

130     public abstract Enumeration JavaDoc getFilterPropertyNames();
131     //AJOUT
132
public abstract Map JavaDoc getFilterProperties();
133     public abstract Map JavaDoc getFilterPropertiesDescription();
134     /**
135      * Sets a property of the filter. Each filter has a set number of
136      * properties that are determined by the filter author.
137      *
138      * @param name the name of the property to set.
139      * @param value the new value for the property.
140      *
141      * @throws IllegalArgumentException if the property trying to be set doesn't
142      * exist.
143      */

144     public abstract void setFilterProperty(String JavaDoc name, String JavaDoc value)
145         throws IllegalArgumentException JavaDoc;
146
147     /**
148      * Saves the properties of the filter through a persistance layer.
149      * Each forum implementation is responsible for providing this layer by
150      * overriding this method.
151      */

152     public void saveFilterProperties() {
153         //Empty - each forum implementation must override this method. The
154
//forum implementation filter wrapper is responsible for calling this
155
//method when filter properties are set.
156
};
157
158     //FROM THE FORUMMESSAGE INTERFACE//
159

160     public int getID() {
161         return message.getID();
162     }
163     //AJOUT
164
public boolean isApproved() {
165             return message.isApproved();
166         }
167         
168     public void setApproved(boolean approved) throws UnauthorizedException {
169          message.setApproved(approved);
170     }
171
172     public Date JavaDoc getCreationDate() {
173         return message.getCreationDate();
174     }
175
176     public void setCreationDate(Date JavaDoc creationDate)
177         throws UnauthorizedException {
178         message.setCreationDate(creationDate);
179     }
180
181     public Date JavaDoc getModifiedDate() {
182         return message.getModifiedDate();
183     }
184
185     public void setModifiedDate(Date JavaDoc modifiedDate)
186         throws UnauthorizedException {
187         message.setModifiedDate(modifiedDate);
188     }
189
190     public String JavaDoc getSubject() {
191         return message.getSubject();
192     }
193
194     public String JavaDoc getUnfilteredSubject() {
195         return message.getUnfilteredSubject();
196     }
197
198     public void setSubject(String JavaDoc subject) throws UnauthorizedException {
199         message.setSubject(subject);
200     }
201
202     public String JavaDoc getBody() {
203         return message.getBody();
204     }
205
206     public String JavaDoc getUnfilteredBody() {
207         return message.getUnfilteredBody();
208     }
209
210     public void setBody(String JavaDoc body) throws UnauthorizedException {
211         this.message.setBody(body);
212     }
213
214     public User getUser() {
215         return message.getUser();
216     }
217
218     public String JavaDoc getProperty(String JavaDoc name) {
219         return message.getProperty(name);
220     }
221
222     public String JavaDoc getUnfilteredProperty(String JavaDoc name) {
223         return message.getUnfilteredBody();
224     }
225
226     public void setProperty(String JavaDoc name, String JavaDoc value) {
227         message.setProperty(name, value);
228     }
229
230     public Iterator JavaDoc propertyNames() {
231         return message.propertyNames();
232     }
233
234     public boolean isAnonymous() {
235         return message.isAnonymous();
236     }
237
238     public ForumThread getForumThread() {
239         return message.getForumThread();
240     }
241
242     public boolean hasPermission(int type) {
243         return message.hasPermission(type);
244     }
245
246     //OTHER METHODS//
247

248     public String JavaDoc toString() {
249         return message.toString();
250     }
251
252     /*public int compareTo(Object o){
253         return this.getDescription().compareTo(((MessageFilter)o).getDescription());
254     }*/

255     
256 }
257
Popular Tags