KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > jforum > entities > Forum


1 /*
2  * Copyright (c) Rafael Steil
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms,
6  * with or without modification, are permitted provided
7  * that the following conditions are met:
8  *
9  * 1) Redistributions of source code must retain the above
10  * copyright notice, this list of conditions and the
11  * following disclaimer.
12  * 2) Redistributions in binary form must reproduce the
13  * above copyright notice, this list of conditions and
14  * the following disclaimer in the documentation and/or
15  * other materials provided with the distribution.
16  * 3) Neither the name of "Rafael Steil" nor
17  * the names of its contributors may be used to endorse
18  * or promote products derived from this software without
19  * specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
22  * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
23  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
24  * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
25  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR
26  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
27  * THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
28  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
29  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES
30  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
32  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
33  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
34  * IN CONTRACT, STRICT LIABILITY, OR TORT
35  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
36  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
37  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
38  *
39  * This file creating date: Feb 23, 2003 / 12:25:04 PM
40  * The JForum Project
41  * http://www.jforum.net
42  */

43 package net.jforum.entities;
44
45 import java.io.Serializable JavaDoc;
46 import java.util.List JavaDoc;
47
48 import net.jforum.repository.ForumRepository;
49
50 /**
51  * Represents a specific forum.
52  *
53  * @author Rafael Steil
54  * @version $Id: Forum.java,v 1.11 2005/09/13 21:27:28 rafaelsteil Exp $
55  */

56 public class Forum implements Serializable JavaDoc
57 {
58     private int id;
59     private int idCategories;
60     private String JavaDoc name;
61     private String JavaDoc description;
62     private int order;
63     private int totalTopics;
64     private int totalPosts;
65     private int lastPostId;
66     private boolean moderated;
67     private boolean unread;
68     private LastPostInfo lpi;
69     private List JavaDoc moderatorList;
70
71     public Forum() { }
72     
73     public Forum(int forumId) {
74         this.id = forumId;
75     }
76     
77     public Forum(Forum f)
78     {
79         this.description = f.getDescription();
80         this.id = f.getId();
81         this.idCategories = f.getCategoryId();
82         this.lastPostId = f.getLastPostId();
83         this.moderated = f.isModerated();
84         this.name = f.getName();
85         this.order = f.getOrder();
86         this.totalPosts = f.getTotalPosts();
87         this.totalTopics = f.getTotalTopics();
88         this.unread = f.getUnread();
89         this.lpi = f.getLastPostInfo();
90         this.moderatorList = f.getModeratorList();
91     }
92     
93     public void setLastPostInfo(LastPostInfo lpi) {
94         this.lpi = lpi;
95     }
96     
97     public LastPostInfo getLastPostInfo() {
98         return this.lpi;
99     }
100     
101     public List JavaDoc getModeratorList()
102     {
103         return ForumRepository.getModeratorList(this.id);
104     }
105     
106     /**
107      * Gets the forum's description
108      *
109      * @return String with the description
110      */

111     public String JavaDoc getDescription() {
112         return this.description;
113     }
114
115     /**
116      * Gets the forum's ID
117      *
118      * @return int value representing the ID
119      */

120     public int getId() {
121         return this.id;
122     }
123
124     /**
125      * Gets the category which the forum belongs to
126      *
127      * @return int value representing the ID of the category
128      */

129     public int getCategoryId() {
130         return this.idCategories;
131     }
132
133     /**
134      * Gets the ID of the last post
135      *
136      * @return int value representing the ID of the post
137      */

138     public int getLastPostId() {
139         return this.lastPostId;
140     }
141
142     /**
143      * Checks if is a moderated forum
144      *
145      * @return boolean value. <code>true</code> if the forum is moderated, <code>false</code> if not.
146      */

147     public boolean isModerated() {
148         return this.moderated;
149     }
150
151     /**
152      * Gets the name of the forum
153      *
154      * @return String with the name
155      */

156     public String JavaDoc getName() {
157         return this.name;
158     }
159
160     /**
161      * Gets the order
162      *
163      * @return int value representing the order of the forum
164      */

165     public int getOrder() {
166         return this.order;
167     }
168
169     /**
170      * Gets the total number of topics posted in the forum
171      *
172      * @return int value with the total number of the topics
173      */

174     public int getTotalTopics() {
175         return this.totalTopics;
176     }
177     
178     public boolean getUnread() {
179         return this.unread;
180     }
181
182     /**
183      * Sets the description.
184      *
185      * @param description The description to set
186      */

187     public void setDescription(String JavaDoc description) {
188         this.description = description;
189     }
190
191     /**
192      * Sets the id.
193      *
194      * @param id The id to set
195      */

196     public void setId(int id) {
197         this.id = id;
198     }
199
200     /**
201      * Sets the category id
202      *
203      * @param idCategories The ID of the category to set to the forum
204      */

205     public void setIdCategories(int idCategories) {
206         this.idCategories = idCategories;
207     }
208
209     /**
210      * Sets the ID of the last post
211      *
212      * @param lastPostId The post id
213      */

214     public void setLastPostId(int lastPostId) {
215         this.lastPostId = lastPostId;
216     }
217
218     /**
219      * Sets the moderated flag to the forum
220      *
221      * @param moderated <code>true</code> or <code>false</code>
222      */

223     public void setModerated(boolean moderated) {
224         this.moderated = moderated;
225     }
226
227     /**
228      * Sets the name of the forum
229      *
230      * @param name The name to set
231      */

232     public void setName(String JavaDoc name) {
233         this.name = name;
234     }
235
236     /**
237      * Sets the order.
238      *
239      * @param order The order to set
240      */

241     public void setOrder(int order) {
242         this.order = order;
243     }
244     
245     public void setUnread(boolean status) {
246         this.unread = status;
247     }
248
249     /**
250      * Sets the total number of topics
251      *
252      * @param totalTopics int value with the total number of topics
253      */

254     public void setTotalTopics(int totalTopics) {
255         this.totalTopics = totalTopics;
256     }
257     
258     public int getTotalPosts() {
259         return this.totalPosts;
260     }
261     
262     public void setTotalPosts(int totalPosts) {
263         this.totalPosts = totalPosts;
264     }
265     
266     /**
267      * @see java.lang.Object#equals(java.lang.Object)
268      */

269     public boolean equals(Object JavaDoc o)
270     {
271         return ((o instanceof Forum) && (((Forum)o).getId() == this.id));
272     }
273
274     /**
275      * @see java.lang.Object#hashCode()
276      */

277     public int hashCode()
278     {
279         return this.id;
280     }
281     
282     /**
283      * @see java.lang.Object#toString()
284      */

285     public String JavaDoc toString() {
286         return "[" + this.name + ", id=" + this.id + ", order=" + this.order + "]";
287     }
288 }
289
Popular Tags