KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > lucane > applications > forum > model > ForumMessage


1 /*
2  * Lucane - a collaborative platform
3  * Copyright (C) 2004 Vincent Fiack <vfiack@mail15.com>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  */

19 package org.lucane.applications.forum.model;
20
21 import java.io.Serializable JavaDoc;
22 import java.util.Date JavaDoc;
23
24 public class ForumMessage implements Serializable JavaDoc
25 {
26     private int id;
27     private int idref;
28     private String JavaDoc title;
29     private Date JavaDoc date;
30     private String JavaDoc author;
31     private String JavaDoc content;
32     private boolean visible;
33       
34     public ForumMessage(int id, int idref, String JavaDoc title, Date JavaDoc date,
35             String JavaDoc author, String JavaDoc content, boolean visible)
36     {
37         this.id = id;
38         this.idref = idref;
39         this.title = title;
40         this.date = date;
41         this.author = author;
42         this.content = content.replaceAll(" \\/\\>", ">");
43         this.visible = visible;
44     }
45     
46     public ForumMessage(int idref, String JavaDoc title, String JavaDoc author, String JavaDoc content)
47     {
48         this(-1, idref, title, new Date JavaDoc(), author, content, true);
49     }
50     
51     public String JavaDoc toString()
52     {
53         return title;
54     }
55     
56     public boolean equals(Object JavaDoc o)
57     {
58         if(o instanceof ForumMessage)
59         {
60             ForumMessage fm = (ForumMessage)o;
61             return fm.title.equals(title) && fm.date.equals(date) && fm.author.equals(author);
62         }
63         
64         return false;
65     }
66     
67     public int hashCode()
68     {
69         return title.hashCode() + date.hashCode() + author.hashCode();
70     }
71     
72     /**
73      * @return Returns the author.
74      */

75     public String JavaDoc getAuthor() {
76         return author;
77     }
78     
79     /**
80      * @return Returns the content.
81      */

82     public String JavaDoc getContent() {
83         return content;
84     }
85     
86     /**
87      * @return Returns the date.
88      */

89     public Date JavaDoc getDate() {
90         return date;
91     }
92     
93     /**
94      * @return Returns the id.
95      */

96     public int getId() {
97         return id;
98     }
99     
100     /**
101      * @return Returns the idref.
102      */

103     public int getIdRef() {
104         return idref;
105     }
106     
107     /**
108      * @return Returns the title.
109      */

110     public String JavaDoc getTitle() {
111         return title;
112     }
113     
114     public boolean isVisible()
115     {
116         return visible;
117     }
118     
119     public void setVisible(boolean value)
120     {
121         this.visible = value;
122     }
123 }
124
Popular Tags