KickJava   Java API By Example, From Geeks To Geeks.

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


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:40:13 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.Date JavaDoc;
47
48 /**
49  * Represents every topic in the forum.
50  *
51  * @author Rafael Steil
52  * @version $Id: Topic.java,v 1.15 2005/11/10 18:30:06 almilli Exp $
53  */

54 public class Topic implements Serializable JavaDoc
55 {
56     public static final int TYPE_NORMAL = 0;
57     public static final int TYPE_STICKY = 1;
58     public static final int TYPE_ANNOUNCE = 2;
59
60     public static final int STATUS_UNLOCKED = 0;
61     public static final int STATUS_LOCKED = 1;
62     
63     private int id;
64     private int forumId;
65     private int totalViews;
66     private int totalReplies;
67     private int status;
68     private int type;
69     private int firstPostId;
70     private int lastPostId;
71     private int voteId;
72     
73     private boolean read = true;
74     private boolean moderated;
75     private boolean isHot;
76     private boolean hasAttach;
77     private boolean paginate;
78     
79     private String JavaDoc firstPostTime;
80     private String JavaDoc lastPostTime;
81     private String JavaDoc title;
82     
83     private Date JavaDoc time;
84     private Date JavaDoc lastPostTimeInMillis;
85     
86     private Double JavaDoc totalPages;
87     
88     private User postedBy;
89     private User lastPostBy;
90     
91     public Topic() {}
92     
93     public Topic(int topicId)
94     {
95         this.id = topicId;
96     }
97     
98     /**
99      * Returns the ID of the firts topic
100      *
101      * @return int value with the ID
102      */

103     public int getFirstPostId() {
104         return this.firstPostId;
105     }
106
107     /**
108      * Returns the ID of the topic
109      *
110      * @return int value with the ID
111      */

112     public int getId() {
113         return this.id;
114     }
115
116     /**
117      * Returns the ID of the forum this topic belongs to
118      *
119      * @return int value with the ID
120      */

121     public int getForumId() {
122         return this.forumId;
123     }
124
125     /**
126      * Teturns the ID of the last post in the topic
127      *
128      * @return int value with the ID
129      */

130     public int getLastPostId() {
131         return this.lastPostId;
132     }
133
134     /**
135      * Returns the status
136      *
137      * @return int value with the status
138      */

139     public int getStatus() {
140         return this.status;
141     }
142
143     /**
144      * Returns the time the topic was posted
145      *
146      * @return int value representing the time
147      */

148     public Date JavaDoc getTime() {
149         return this.time;
150     }
151     
152     public void setFirstPostTime(String JavaDoc d) {
153         this.firstPostTime = d;
154     }
155     
156     public void setLastPostTime(String JavaDoc d) {
157         this.lastPostTime = d;
158     }
159
160     /**
161      * Returns the title of the topci
162      *
163      * @return String with the topic title
164      */

165     public String JavaDoc getTitle() {
166         return (this.title == null ? "" : this.title);
167     }
168
169     /**
170      * Returns the total number of replies
171      *
172      * @return int value with the total
173      */

174     public int getTotalReplies() {
175         return this.totalReplies;
176     }
177
178     /**
179      * Returns the total number of views
180      *
181      * @return int value with the total number of views
182      */

183     public int getTotalViews() {
184         return this.totalViews;
185     }
186     
187     public User getPostedBy() {
188         return this.postedBy;
189     }
190     
191     public User getLastPostBy() {
192         return this.lastPostBy;
193     }
194
195     /**
196      * Returns the type
197      *
198      * @return int value representing the type
199      */

200     public int getType() {
201         return this.type;
202     }
203
204     /**
205      * Is a votation topic?
206      *
207      * @return boolean value
208      */

209     public boolean isVote() {
210         return this.voteId != 0;
211     }
212
213     /**
214      * Is a votation topic? If so, this is the vote Id
215      *
216      * @return boolean value
217      */

218     public int getVoteId() {
219         return this.voteId;
220     }
221
222     /**
223      * Sets the id of the firts post in the topic
224      *
225      * @param firstPostId The post id
226      */

227     public void setFirstPostId(int firstPostId) {
228         this.firstPostId = firstPostId;
229     }
230
231     /**
232      * Sets the id to the topic
233      *
234      * @param id The id to set
235      */

236     public void setId(int id) {
237         this.id = id;
238     }
239
240     /**
241      * Sets the id of the forum associeted with this topic
242      *
243      * @param idForum The id of the forum to set
244      */

245     public void setForumId(int idForum) {
246         this.forumId = idForum;
247     }
248
249     /**
250      * Sets the id of the last post in the topic
251      *
252      * @param lastPostId The post id
253      */

254     public void setLastPostId(int lastPostId) {
255         this.lastPostId = lastPostId;
256     }
257
258     /**
259      * Sets the status.
260      *
261      * @param status The status to set
262      */

263     public void setStatus(int status) {
264         this.status = status;
265     }
266
267     /**
268      * Sets the time.
269      *
270      * @param time The time to set
271      */

272     public void setTime(Date JavaDoc time) {
273         this.time = time;
274     }
275
276     /**
277      * Sets the title.
278      *
279      * @param title The title to set
280      */

281     public void setTitle(String JavaDoc title) {
282         this.title = title;
283     }
284
285     /**
286      * Sets the totalReplies.
287      *
288      * @param totalReplies The totalReplies to set
289      */

290     public void setTotalReplies(int totalReplies) {
291         this.totalReplies = totalReplies;
292     }
293
294     /**
295      * Sets the totalViews.
296      *
297      * @param totalViews The totalViews to set
298      */

299     public void setTotalViews(int totalViews) {
300         this.totalViews = totalViews;
301     }
302
303     /**
304      * Sets the type.
305      *
306      * @param type The type to set
307      */

308     public void setType(int type) {
309         this.type = type;
310     }
311
312     /**
313      * Sets the voteId.
314      *
315      * @param voteId The voteId to set
316      */

317     public void setVoteId(int voteId) {
318         this.voteId = voteId;
319     }
320     /**
321      * @return
322      */

323     public boolean isModerated() {
324         return this.moderated;
325     }
326
327     /**
328      * @param b
329      */

330     public void setModerated(boolean b) {
331         this.moderated = b;
332     }
333     
334     public void setPostedBy(User u) {
335         this.postedBy = u;
336     }
337     
338     public void setLastPostBy(User u) {
339         this.lastPostBy = u;
340     }
341     
342     public String JavaDoc getFirstPostTime() {
343         return this.firstPostTime;
344     }
345     
346     public String JavaDoc getLastPostTime() {
347         return this.lastPostTime;
348     }
349
350     public void setRead(boolean read) {
351         this.read = read;
352     }
353     
354     public boolean getRead() {
355         return this.read;
356     }
357     
358     public void setLastPostDate(Date JavaDoc t) {
359         this.lastPostTimeInMillis = t;
360     }
361     
362     public Date JavaDoc getLastPostDate() {
363         return this.lastPostTimeInMillis;
364     }
365     
366     public void setPaginate(boolean paginate) {
367         this.paginate = paginate;
368     }
369     
370     public boolean getPaginate() {
371         return this.paginate;
372     }
373     
374     public void setTotalPages(Double JavaDoc total) {
375         this.totalPages = total;
376     }
377     
378     public Double JavaDoc getTotalPages() {
379         return this.totalPages;
380     }
381     
382     public void setHot(boolean hot) {
383         this.isHot = hot;
384     }
385     
386     public boolean isHot() {
387         return this.isHot;
388     }
389     
390     public void setHasAttach(boolean b)
391     {
392         this.hasAttach = b;
393     }
394     
395     public boolean hasAttach()
396     {
397         return this.hasAttach;
398     }
399     
400     /**
401      * @see java.lang.Object#equals(java.lang.Object)
402      */

403     public boolean equals(Object JavaDoc o)
404     {
405         if (!(o instanceof Topic)) {
406             return false;
407         }
408         
409         return (((Topic)o).getId() == this.id);
410     }
411     /**
412      * @see java.lang.Object#hashCode()
413      */

414     public int hashCode()
415     {
416         return this.id;
417     }
418     
419     /**
420      * @see java.lang.Object#toString()
421      */

422     public String JavaDoc toString()
423     {
424         return "[" + this.id + ", " + this.title + "]";
425     }
426 }
427
Popular Tags