KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > j2biz > blogunity > pojo > Comment


1 /*
2  * $Id: Comment.java,v 1.4 2004/12/30 19:11:19 keyboardsamurai Exp $
3  *
4  * Copyright (c) 2004 j2biz Group, http://www.j2biz.com
5  * Koeln / Duesseldorf , Germany
6  *
7  * @author Max Kalina
8  *
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23  *
24  */

25
26 package com.j2biz.blogunity.pojo;
27
28 import java.io.Serializable JavaDoc;
29 import java.util.Date JavaDoc;
30 import java.util.Set JavaDoc;
31 import java.util.TreeSet JavaDoc;
32
33 import com.j2biz.blogunity.util.CommentComparator;
34
35 /**
36  * @hibernate.class table="COMMENTS" dynamic-insert = "true"
37  * dynamic-update = "true"
38  *
39  * @author michelson
40  * @version $$
41  * @since 0.1
42  *
43  *
44  */

45 public class Comment implements Serializable JavaDoc{
46
47     /**
48      * Comment for <code>serialVersionUID</code>
49      */

50     private static final long serialVersionUID = 3258412850275168817L;
51
52     private Long JavaDoc id;
53
54     private String JavaDoc title;
55
56     private String JavaDoc rawTitle;
57
58     private String JavaDoc body;
59
60     private String JavaDoc rawBody;
61
62     private User author;
63
64     private String JavaDoc authorIP = "127.0.0.1";
65
66     private Entry commentedEntry;
67
68     private Comment repliedComment;
69
70     private Date JavaDoc createTime = new Date JavaDoc();
71
72     private Set JavaDoc /* <Comment> */answers = new TreeSet JavaDoc(
73             new CommentComparator());
74
75     private Userpic userpic;
76
77     /**
78      *
79      */

80     public Comment() {
81         super();
82     }
83
84     /**
85      * @hibernate.set name="answers" inverse="true"
86      * sort="com.j2biz.blogunity.util.CommentComparator"
87      * cascade="save-update" lazy="true"
88      *
89      * @hibernate.collection-key column="REPLIED_COMMENT_ID"
90      * @hibernate.collection-one-to-many class="com.j2biz.blogunity.pojo.Comment"
91      *
92      * @return Returns the answers.
93      */

94     public Set JavaDoc getAnswers() {
95         return answers;
96     }
97
98     /**
99      * @param answers
100      * The answers to set.
101      */

102     public void setAnswers(Set JavaDoc answers) {
103         this.answers = answers;
104     }
105
106     /**
107      * @hibernate.many-to-one column="AUTHOR_ID"
108      * class="com.j2biz.blogunity.pojo.User"
109      *
110      * @return Returns the author.
111      */

112     public User getAuthor() {
113         return author;
114     }
115
116     /**
117      * @param author
118      * The author to set.
119      */

120     public void setAuthor(User author) {
121         this.author = author;
122     }
123
124     /**
125      * @hibernate.property name="body" column="BODY" type="text"
126      * not-null="false" unique="false"
127      *
128      * @return Returns the body.
129      */

130     public String JavaDoc getBody() {
131         return body;
132     }
133
134     /**
135      * @param body
136      * The body to set.
137      */

138     public void setBody(String JavaDoc body) {
139         this.body = body;
140     }
141
142     /**
143      * @hibernate.property name="rawBody" column="RAW_BODY"
144      * type="text" not-null="false" unique="false"
145      *
146      *
147      * @return Returns the rawBody.
148      */

149     public String JavaDoc getRawBody() {
150         return rawBody;
151     }
152
153     /**
154      * @param rawBody
155      * The rawBody to set.
156      */

157     public void setRawBody(String JavaDoc rawBody) {
158         this.rawBody = rawBody;
159     }
160
161     /**
162      * @hibernate.many-to-one column="ENTRY_ID"
163      * class="com.j2biz.blogunity.pojo.Entry"
164      *
165      * @return Returns the commentedEntry.
166      */

167     public Entry getCommentedEntry() {
168         return commentedEntry;
169     }
170
171     /**
172      * @param commentedEntry
173      * The commentedEntry to set.
174      */

175     public void setCommentedEntry(Entry commentedEntry) {
176         this.commentedEntry = commentedEntry;
177     }
178
179     /**
180      * @hibernate.property name="createTime" column="CREATE_TIME"
181      * type="timestamp" not-null="true"
182      * unique="false"
183      *
184      * @return Returns the createTime.
185      */

186     public Date JavaDoc getCreateTime() {
187         return createTime;
188     }
189
190     /**
191      * @param createTime
192      * The createTime to set.
193      */

194     public void setCreateTime(Date JavaDoc createTime) {
195         this.createTime = createTime;
196     }
197
198     /**
199      * @hibernate.id generator-class="increment" type="long"
200      * column="ID" unsaved-value="null"
201      *
202      * @return Returns the id.
203      */

204     public Long JavaDoc getId() {
205         return id;
206     }
207
208     /**
209      * @param id
210      * The id to set.
211      */

212     public void setId(Long JavaDoc id) {
213         this.id = id;
214     }
215
216     /**
217      * @hibernate.many-to-one column="REPLIED_COMMENT_ID"
218      * class="com.j2biz.blogunity.pojo.Comment"
219      *
220      * @return Returns the repliedComment.
221      */

222     public Comment getRepliedComment() {
223         return repliedComment;
224     }
225
226     /**
227      * @param repliedComment
228      * The repliedComment to set.
229      */

230     public void setRepliedComment(Comment repliedComment) {
231         this.repliedComment = repliedComment;
232     }
233
234     /**
235      * @hibernate.property name="title" column="TITLE" type="string"
236      * not-null="true" unique="false"
237      *
238      * @return Returns the title.
239      */

240     public String JavaDoc getTitle() {
241         return title;
242     }
243
244     /**
245      * @param title
246      * The title to set.
247      */

248     public void setTitle(String JavaDoc title) {
249         this.title = title;
250     }
251
252     /**
253      * @hibernate.property name="rawTitle" column="RAW_TITLE"
254      * type="string" not-null="true"
255      * unique="false"
256      *
257      *
258      * @return Returns the rawTitle.
259      */

260     public String JavaDoc getRawTitle() {
261         return rawTitle;
262     }
263
264     /**
265      * @param rawTitle
266      * The rawTitle to set.
267      */

268     public void setRawTitle(String JavaDoc rawTitle) {
269         this.rawTitle = rawTitle;
270     }
271
272     /**
273      * @hibernate.property name="authorIP" column="AUTHOR_IP"
274      * type="string" not-null="true"
275      * unique="false"
276      *
277      * @return Returns the authorIP.
278      */

279     public String JavaDoc getAuthorIP() {
280         return authorIP;
281     }
282
283     /**
284      * @param authorIP
285      * The authorIP to set.
286      */

287     public void setAuthorIP(String JavaDoc authorIP) {
288         this.authorIP = authorIP;
289     }
290
291     /**
292      * @hibernate.many-to-one column="USERPIC_ID"
293      * class="com.j2biz.blogunity.pojo.Userpic"
294      *
295      * @return Returns the userpic.
296      */

297     public Userpic getUserpic() {
298         return userpic;
299     }
300
301     /**
302      * @param userpic
303      * The userpic to set.
304      */

305     public void setUserpic(Userpic userpic) {
306         this.userpic = userpic;
307     }
308
309     public int getLevel() {
310         if (getRepliedComment() != null) {
311             return getRepliedComment().getLevel() + 1;
312         } else
313             return 0;
314     }
315
316 }
Popular Tags