KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > Yasna > forum > ForumMessageFilter


1 /**
2  * Copyright (C) 2001 Yasna.com. All rights reserved.
3  *
4  * ===================================================================
5  * The Apache Software License, Version 1.1
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * 1. Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  *
14  * 2. Redistributions in binary form must reproduce the above copyright
15  * notice, this list of conditions and the following disclaimer in
16  * the documentation and/or other materials provided with the
17  * distribution.
18  *
19  * 3. The end-user documentation included with the redistribution,
20  * if any, must include the following acknowledgment:
21  * "This product includes software developed by
22  * Yasna.com (http://www.yasna.com)."
23  * Alternately, this acknowledgment may appear in the software itself,
24  * if and wherever such third-party acknowledgments normally appear.
25  *
26  * 4. The names "Yazd" and "Yasna.com" must not be used to
27  * endorse or promote products derived from this software without
28  * prior written permission. For written permission, please
29  * contact yazd@yasna.com.
30  *
31  * 5. Products derived from this software may not be called "Yazd",
32  * nor may "Yazd" appear in their name, without prior written
33  * permission of Yasna.com.
34  *
35  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
36  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
37  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
38  * DISCLAIMED. IN NO EVENT SHALL YASNA.COM OR
39  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
40  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
41  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
42  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
43  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
44  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
45  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
46  * SUCH DAMAGE.
47  * ====================================================================
48  *
49  * This software consists of voluntary contributions made by many
50  * individuals on behalf of Yasna.com. For more information
51  * on Yasna.com, please see <http://www.yasna.com>.
52  */

53
54 /**
55  * Copyright (C) 2000 CoolServlets.com. All rights reserved.
56  *
57  * ===================================================================
58  * The Apache Software License, Version 1.1
59  *
60  * Redistribution and use in source and binary forms, with or without
61  * modification, are permitted provided that the following conditions
62  * are met:
63  *
64  * 1. Redistributions of source code must retain the above copyright
65  * notice, this list of conditions and the following disclaimer.
66  *
67  * 2. Redistributions in binary form must reproduce the above copyright
68  * notice, this list of conditions and the following disclaimer in
69  * the documentation and/or other materials provided with the
70  * distribution.
71  *
72  * 3. The end-user documentation included with the redistribution,
73  * if any, must include the following acknowledgment:
74  * "This product includes software developed by
75  * CoolServlets.com (http://www.coolservlets.com)."
76  * Alternately, this acknowledgment may appear in the software itself,
77  * if and wherever such third-party acknowledgments normally appear.
78  *
79  * 4. The names "Jive" and "CoolServlets.com" must not be used to
80  * endorse or promote products derived from this software without
81  * prior written permission. For written permission, please
82  * contact webmaster@coolservlets.com.
83  *
84  * 5. Products derived from this software may not be called "Jive",
85  * nor may "Jive" appear in their name, without prior written
86  * permission of CoolServlets.com.
87  *
88  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
89  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
90  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
91  * DISCLAIMED. IN NO EVENT SHALL COOLSERVLETS.COM OR
92  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
93  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
94  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
95  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
96  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
97  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
98  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
99  * SUCH DAMAGE.
100  * ====================================================================
101  *
102  * This software consists of voluntary contributions made by many
103  * individuals on behalf of CoolServlets.com. For more information
104  * on CoolServlets.com, please see <http://www.coolservlets.com>.
105  */

106
107 package com.Yasna.forum;
108
109 import java.util.*;
110 import java.io.*;
111
112 /**
113  * A filter acts as a layer between a forum skin and a real ForumMessage
114  * object. It provides extended functionality by dynamically reformatting
115  * ForumMessage contents.
116  * <p>
117  * An unlimited number of ForumMessageFilters can be specified to be applied
118  * per Forum. Object-oriented designers will recognize this class as a
119  * Decorator for ForumMessages.
120  *
121  * @see ForumMessage
122  */

123 public abstract class ForumMessageFilter implements ForumMessage, Serializable
124 {
125
126     /**
127      * The underlying message the filter is applied to.
128      */

129     protected ForumMessage message = null;
130
131     /**
132      * Creates a new filter not associated with a message. This is
133      * generally only useful for defining a template filter that other
134      * fitlers will be cloned from.
135      */

136     public ForumMessageFilter() {
137         //do nothing;
138
}
139
140     /**
141      * Creates a new filter wrapped around the specified message.
142      *
143      * @param message the ForumMessage to wrap the new filter around.
144      */

145     public ForumMessageFilter(ForumMessage message) {
146         this.message = message;
147     }
148
149     /**
150      * Clones a new filter that will have the same properties and that
151      * will wrap around the specified message.
152      *
153      * @param message the ForumMessage to wrap the new filter around.
154      */

155     public abstract ForumMessageFilter clone(ForumMessage message);
156
157     /**
158      * Returns the name of the filter.
159      *
160      * @return the name of the filter.
161      */

162     public abstract String JavaDoc getName();
163
164     /**
165      * Returns a description of the filter. The description of the filter should
166      * include information about what the filter does, as well as any critical
167      * usage notes.
168      *
169      * @return the description of the filter.
170      */

171     public abstract String JavaDoc getDescription();
172
173     /**
174      * Returns a URL that has documentation about the filter. By default, the
175      * method returns null, which means that no documentation is available.<p>
176      *
177      * Documentation should include installation as well as usage guidlines.
178      *
179      * @return a URL with documentation about the filter, or null if no
180      * documentation is available.
181      */

182     public String JavaDoc getDocumentationURL() {
183         return null;
184     }
185
186     /**
187      * Returns the author of the filter.
188      *
189      * @return the author of the filter.
190      */

191     public abstract String JavaDoc getAuthor();
192
193     /**
194      * Returns the major version number of the filter. For example it would
195      * return the value of "x" in x.0. Major version numbers should be
196      * incremented for new releases of filters that introduct significant new
197      * functionality
198      *
199      * @return the major version number of the filter.
200      */

201     public abstract int getMajorVersion();
202
203     /**
204      * Returns the minor version number of the filter. For example it would
205      * return the value of "x" in 1.x. Minor version numbers should be
206      * incremented for new releases of filters that fix bugs or add minor
207      * functionality.
208      *
209      * @return the minor version number of the filter
210      */

211     public abstract int getMinorVersion();
212
213     /**
214      * Returns the value of a property of the filter.
215      *
216      * @param name the name of the property.
217      * @return the value of the property.
218      */

219     public abstract String JavaDoc getFilterProperty(String JavaDoc name);
220
221     /**
222      * Returns the description of a property of the filter.
223      *
224      * @param name the name of the property.
225      * @return the description of the property.
226      */

227     public abstract String JavaDoc getFilterPropertyDescription(String JavaDoc name);
228
229     /**
230      * Returns an enumeration of the property names of the filter.
231      *
232      * @return an enumeration of the property names of the filter.
233      */

234     public abstract Enumeration filterPropertyNames();
235
236     /**
237      * Sets a property of the filter. Each filter has a set number of
238      * properties that are determined by the filter author.
239      *
240      * @param name the name of the property to set.
241      * @param value the new value for the property.
242      *
243      * @throws IllegalArgumentException if the property trying to be set doesn't
244      * exist.
245      */

246     public abstract void setFilterProperty(String JavaDoc name, String JavaDoc value)
247             throws IllegalArgumentException JavaDoc;
248
249     /**
250      * Saves the properties of the filter through a persistance layer.
251      * Each forum implementation is responsible for providing this layer by
252      * overriding this method.
253      */

254     public void saveFilterProperties() {
255         //Empty - each forum implementation must override this method. The
256
//forum implementation filter wrapper is responsible for calling this
257
//method when filter properties are set.
258
};
259
260     //FROM THE FORUMMESSAGE INTERFACE//
261

262     public int getID() {
263         return message.getID();
264     }
265
266     public Date getCreationDate() {
267         return message.getCreationDate();
268     }
269
270     public void setCreationDate(Date creationDate) throws UnauthorizedException
271     {
272         message.setCreationDate(creationDate);
273     }
274
275     public Date getModifiedDate() {
276         return message.getModifiedDate();
277     }
278
279     public void setModifiedDate(Date modifiedDate) throws UnauthorizedException
280     {
281         message.setModifiedDate(modifiedDate);
282     }
283
284     public String JavaDoc getSubject() {
285         return message.getSubject();
286     }
287
288     public int getReplyPrivateUserId() {
289         return message.getReplyPrivateUserId();
290     }
291
292     public boolean isPrivate() {
293         return message.isPrivate();
294     }
295
296     public String JavaDoc getUnfilteredSubject() {
297         return message.getUnfilteredSubject();
298     }
299
300     public void setSubject(String JavaDoc subject) throws UnauthorizedException {
301         message.setSubject(subject);
302     }
303
304     public void setReplyPrivateUserId(int replyPrivateUserId) throws UnauthorizedException {
305         message.setReplyPrivateUserId(replyPrivateUserId);
306     }
307
308     public String JavaDoc getBody() {
309         return message.getBody();
310     }
311
312     public String JavaDoc getUnfilteredBody() {
313         return message.getUnfilteredBody();
314     }
315
316     public void setBody(String JavaDoc body) throws UnauthorizedException {
317         this.message.setBody(body);
318     }
319
320     public void setApprovment(boolean approve) throws UnauthorizedException {
321         this.message.setApprovment(approve);
322     }
323
324     public User getUser() {
325         return message.getUser();
326     }
327
328     public String JavaDoc getProperty(String JavaDoc name) {
329         return message.getProperty(name);
330     }
331
332     public String JavaDoc getUnfilteredProperty(String JavaDoc name) {
333         return message.getUnfilteredBody();
334     }
335
336     public void setProperty(String JavaDoc name, String JavaDoc value) {
337         message.setProperty(name, value);
338     }
339
340     public Iterator propertyNames() {
341         return message.propertyNames();
342     }
343
344     public boolean isAnonymous() {
345         return message.isAnonymous();
346     }
347
348     public boolean isApproved() {
349         return message.isApproved();
350     }
351
352     public ForumThread getForumThread() {
353         return message.getForumThread();
354     }
355
356     public boolean hasPermission(int type) {
357         return message.hasPermission(type);
358     }
359     public MessageRanking getRanking(){
360         return message.getRanking();
361     }
362     public void setRanking(int para) throws UnauthorizedException{
363         message.setRanking(para);
364     }
365
366
367     //OTHER METHODS//
368

369     public String JavaDoc toString() {
370         return message.toString();
371     }
372 }
373
Popular Tags