KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > nemesis > forum > impl > DbForumMessageFilter


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.impl;
26
27 import java.io.Serializable JavaDoc;
28 import java.util.Enumeration JavaDoc;
29 import java.util.Map JavaDoc;
30
31 import org.nemesis.forum.Message;
32 import org.nemesis.forum.MessageFilter;
33
34 /**
35  * Provides database persistence of ForumMessageFilter properties. When the
36  * database implementation of the forum system is used, all filters are
37  * wrapped with an instance of this class.
38  */

39 public class DbForumMessageFilter extends MessageFilter implements Serializable JavaDoc {
40
41     /**
42      * Reference to the forum object this filter belongs to. It's neeeded so
43      * that we can save the state of the filter properties.
44      */

45     private transient DbForum forum;
46
47     public DbForumMessageFilter(Message message, DbForum forum) {
48         this.message = message;
49         this.forum = forum;
50     }
51
52     /**
53      * Clones a new filter that will have the same properties and that
54      * will wrap around the specified message.
55      *
56      * @param message the ForumMessage to wrap the new filter around.
57      */

58     public MessageFilter clone(Message message) {
59         return ((MessageFilter) message).clone(message);
60     }
61
62     /**
63      * Returns the name of the filter.
64      */

65     public String JavaDoc getName() {
66         return ((MessageFilter) message).getName();
67     }
68
69     /**
70      * Returns a description of the filter.
71      */

72     public String JavaDoc getDescription() {
73         return ((MessageFilter) message).getDescription();
74     }
75
76     
77
78
79     /**
80      * Gets a property of the filter by name.
81      *
82      * @param name the name of the property to get.
83      */

84     public String JavaDoc getFilterProperty(String JavaDoc name) {
85         return ((MessageFilter) message).getFilterProperty(name);
86     }
87
88     /**
89      * Sets a property of the filter.
90      *
91      * @param name the name of the property to set
92      * @param value the new value for the property
93      */

94     public void setFilterProperty(String JavaDoc name, String JavaDoc value) throws IllegalArgumentException JavaDoc {
95         ((MessageFilter) message).setFilterProperty(name, value);
96         //Save properties to db
97
saveFilterProperties();
98     }
99     //AJOUT
100
public Map JavaDoc getFilterProperties(){
101         return ((MessageFilter) message).getFilterProperties();
102         
103     }
104     // AJOUT
105
public Map JavaDoc getFilterPropertiesDescription(){
106           return ((MessageFilter) message).getFilterPropertiesDescription();
107         
108       }
109
110     /**
111      * Returns an iterator for the property names for the filter.
112      */

113     public Enumeration JavaDoc getFilterPropertyNames() {
114         return ((MessageFilter) message).getFilterPropertyNames();
115     }
116
117     /**
118      * Saves the state of the filter. Each forum implementation is
119      * responsible for implementing this method.
120      */

121     public void saveFilterProperties() {
122         forum.saveFiltersToDb();
123     }
124
125     /**
126      * Returns a property description.
127      *
128      * @param name the name of the property to get a description of.
129      */

130     public String JavaDoc getFilterPropertyDescription(String JavaDoc name) {
131         return ((MessageFilter) message).getFilterPropertyDescription(name);
132     }
133
134     /**
135      * Converts the object to a String by returning the name of the message.
136      * This functionality is primarily for Java applications that might be
137      * accessing objects through a GUI.
138      */

139     public String JavaDoc toString() {
140         return message.toString();
141     }
142 }
143
Popular Tags