001: /*
002: * Copyright (c) JForum Team
003: * All rights reserved.
004: *
005: * Redistribution and use in source and binary forms,
006: * with or without modification, are permitted provided
007: * that the following conditions are met:
008: *
009: * 1) Redistributions of source code must retain the above
010: * copyright notice, this list of conditions and the
011: * following disclaimer.
012: * 2) Redistributions in binary form must reproduce the
013: * above copyright notice, this list of conditions and
014: * the following disclaimer in the documentation and/or
015: * other materials provided with the distribution.
016: * 3) Neither the name of "Rafael Steil" nor
017: * the names of its contributors may be used to endorse
018: * or promote products derived from this software without
019: * specific prior written permission.
020: *
021: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
022: * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
023: * EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
024: * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
025: * MERCHANTABILITY AND FITNESS FOR A PARTICULAR
026: * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
027: * THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
028: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
029: * EXEMPLARY, OR CONSEQUENTIAL DAMAGES
030: * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
031: * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
032: * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
033: * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
034: * IN CONTRACT, STRICT LIABILITY, OR TORT
035: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
036: * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
037: * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
038: *
039: * This file creating date: Feb 23, 2003 / 12:40:13 PM
040: * The JForum Project
041: * http://www.jforum.net
042: */
043: package net.jforum.entities;
044:
045: import java.io.Serializable;
046: import java.util.Date;
047:
048: /**
049: * Represents every topic in the forum.
050: *
051: * @author Rafael Steil
052: * @version $Id: Topic.java,v 1.18 2007/08/01 22:09:03 rafaelsteil Exp $
053: */
054: public class Topic implements Serializable {
055: public static final int TYPE_NORMAL = 0;
056: public static final int TYPE_STICKY = 1;
057: public static final int TYPE_ANNOUNCE = 2;
058:
059: public static final int STATUS_UNLOCKED = 0;
060: public static final int STATUS_LOCKED = 1;
061:
062: private int id;
063: private int forumId;
064: private int totalViews;
065: private int totalReplies;
066: private int status;
067: private int type;
068: private int firstPostId;
069: private int lastPostId;
070: private int voteId;
071: private int movedId;
072:
073: private boolean read = true;
074: private boolean moderated;
075: private boolean isHot;
076: private boolean hasAttach;
077: private boolean paginate;
078:
079: private String firstPostTime;
080: private String lastPostTime;
081: private String title;
082:
083: private Date time;
084: private Date lastPostDate;
085:
086: private Double totalPages;
087:
088: private User postedBy;
089: private User lastPostBy;
090:
091: public Topic() {
092: }
093:
094: public Topic(int topicId) {
095: this .id = topicId;
096: }
097:
098: /**
099: * 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 getTime() {
149: return this .time;
150: }
151:
152: public void setFirstPostTime(String d) {
153: this .firstPostTime = d;
154: }
155:
156: public void setLastPostTime(String 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 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 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 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: /**
322: * @return
323: */
324: public boolean isModerated() {
325: return this .moderated;
326: }
327:
328: /**
329: * @param b
330: */
331: public void setModerated(boolean b) {
332: this .moderated = b;
333: }
334:
335: public void setPostedBy(User u) {
336: this .postedBy = u;
337: }
338:
339: public void setLastPostBy(User u) {
340: this .lastPostBy = u;
341: }
342:
343: public String getFirstPostTime() {
344: return this .firstPostTime;
345: }
346:
347: public String getLastPostTime() {
348: return this .lastPostTime;
349: }
350:
351: public void setRead(boolean read) {
352: this .read = read;
353: }
354:
355: public boolean getRead() {
356: return this .read;
357: }
358:
359: public void setLastPostDate(Date t) {
360: this .lastPostDate = t;
361: }
362:
363: public Date getLastPostDate() {
364: return this .lastPostDate;
365: }
366:
367: public void setPaginate(boolean paginate) {
368: this .paginate = paginate;
369: }
370:
371: public boolean getPaginate() {
372: return this .paginate;
373: }
374:
375: public void setTotalPages(Double total) {
376: this .totalPages = total;
377: }
378:
379: public Double getTotalPages() {
380: return this .totalPages;
381: }
382:
383: public void setHot(boolean hot) {
384: this .isHot = hot;
385: }
386:
387: public boolean isHot() {
388: return this .isHot;
389: }
390:
391: public void setHasAttach(boolean b) {
392: this .hasAttach = b;
393: }
394:
395: public boolean hasAttach() {
396: return this .hasAttach;
397: }
398:
399: /**
400: * @see java.lang.Object#equals(java.lang.Object)
401: */
402: public boolean equals(Object o) {
403: if (!(o instanceof Topic)) {
404: return false;
405: }
406:
407: return (((Topic) o).getId() == this .id);
408: }
409:
410: /**
411: * @see java.lang.Object#hashCode()
412: */
413: public int hashCode() {
414: return this .id;
415: }
416:
417: /**
418: * @see java.lang.Object#toString()
419: */
420: public String toString() {
421: return "[" + this .id + ", " + this .title + "]";
422: }
423:
424: /**
425: * @return the movedId
426: */
427: public int getMovedId() {
428: return this .movedId;
429: }
430:
431: /**
432: * @param movedId the movedId to set
433: */
434: public void setMovedId(int movedId) {
435: this.movedId = movedId;
436: }
437: }
|