KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > roller > pojos > CommentData


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. The ASF licenses this file to You
4  * under the Apache License, Version 2.0 (the "License"); you may not
5  * use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License. For additional information regarding
15  * copyright in this work, please see the NOTICE file in the top level
16  * directory of this distribution.
17  */

18 package org.apache.roller.pojos;
19
20 import java.sql.Timestamp JavaDoc;
21 import org.apache.roller.util.PojoUtil;
22
23 /**
24  * Weblogentry Comment bean.
25  * @author Lance Lavandowska
26  *
27  * @ejb:bean name="CommentData"
28  * @struts.form include-all="true"
29  *
30  * @hibernate.class lazy="false" table="roller_comment"
31  * @hibernate.cache usage="read-write"
32  */

33 public class CommentData extends org.apache.roller.pojos.PersistentObject
34         implements java.io.Serializable JavaDoc {
35     public static final long serialVersionUID = -6668122596726478462L;
36     
37     private String JavaDoc id = null;
38     private String JavaDoc name = null;
39     private String JavaDoc email = null;
40     private String JavaDoc url = null;
41     private String JavaDoc content = null;
42     private Timestamp JavaDoc postTime = null;
43     private Boolean JavaDoc spam = Boolean.FALSE;
44     private Boolean JavaDoc notify = Boolean.FALSE;
45     private String JavaDoc remoteHost = null;
46     private Boolean JavaDoc pending = null;
47     private Boolean JavaDoc approved = null;
48     private WeblogEntryData weblogEntry = null;
49     
50     
51     public CommentData() {
52         spam = Boolean.FALSE;
53     }
54     
55     public CommentData(java.lang.String JavaDoc id, WeblogEntryData entry,
56             java.lang.String JavaDoc name, java.lang.String JavaDoc email,
57             java.lang.String JavaDoc url, java.lang.String JavaDoc content,
58             java.sql.Timestamp JavaDoc postTime,
59             Boolean JavaDoc spam, Boolean JavaDoc notify,
60             Boolean JavaDoc pending, Boolean JavaDoc approved) {
61         this.id = id;
62         this.name = name;
63         this.email = email;
64         this.url = url;
65         this.content = content;
66         this.postTime = postTime;
67         this.spam = spam;
68         this.notify = notify;
69         this.pending = pending;
70         this.approved = approved;
71         
72         weblogEntry = entry;
73     }
74     
75     public CommentData(CommentData otherData) {
76         this.setData(otherData);
77     }
78     
79     /**
80      * @roller.wrapPojoMethod type="simple"
81      * @ejb:persistent-field
82      * @hibernate.id column="id"
83      * generator-class="uuid.hex" unsaved-value="null"
84      */

85     public java.lang.String JavaDoc getId() {
86         return this.id;
87     }
88     
89     /** @ejb:persistent-field */
90     public void setId(java.lang.String JavaDoc id) {
91         this.id = id;
92     }
93     
94     /**
95      * @roller.wrapPojoMethod type="pojo"
96      * @ejb:persistent-field
97      * @hibernate.many-to-one column="entryid" cascade="none" not-null="true"
98      */

99     public WeblogEntryData getWeblogEntry() {
100         return weblogEntry;
101     }
102     
103     /** @ejb:persistent-field */
104     public void setWeblogEntry(WeblogEntryData entry) {
105         weblogEntry = entry;
106     }
107     
108     /**
109      * @roller.wrapPojoMethod type="simple"
110      * @ejb:persistent-field
111      * @hibernate.property column="name" non-null="true" unique="false"
112      */

113     public java.lang.String JavaDoc getName() {
114         return this.name;
115     }
116     
117     /** @ejb:persistent-field */
118     public void setName(java.lang.String JavaDoc name) {
119         this.name = name;
120     }
121     
122     /**
123      * Email
124      *
125      * @roller.wrapPojoMethod type="simple"
126      * @ejb:persistent-field
127      * @hibernate.property column="email" non-null="true" unique="false"
128      */

129     public java.lang.String JavaDoc getEmail() {
130         return this.email;
131     }
132     
133     /** @ejb:persistent-field */
134     public void setEmail(java.lang.String JavaDoc email) {
135         this.email = email;
136     }
137     
138     /**
139      * @roller.wrapPojoMethod type="simple"
140      * @ejb:persistent-field
141      * @hibernate.property column="url" non-null="true" unique="false"
142      */

143     public java.lang.String JavaDoc getUrl() {
144         return this.url;
145     }
146     
147     /** @ejb:persistent-field */
148     public void setUrl(java.lang.String JavaDoc url) {
149         this.url = url;
150     }
151     
152     /**
153      * @roller.wrapPojoMethod type="simple"
154      * @ejb:persistent-field
155      * @hibernate.property column="content" non-null="true" unique="false"
156      */

157     public java.lang.String JavaDoc getContent() {
158         return this.content;
159     }
160     
161     /** @ejb:persistent-field */
162     public void setContent(java.lang.String JavaDoc content) {
163         this.content = content;
164     }
165     
166     /**
167      * @roller.wrapPojoMethod type="simple"
168      * @ejb:persistent-field
169      * @hibernate.property column="posttime" non-null="true" unique="false"
170      */

171     public java.sql.Timestamp JavaDoc getPostTime() {
172         return this.postTime;
173     }
174     
175     /** @ejb:persistent-field */
176     public void setPostTime(java.sql.Timestamp JavaDoc postTime) {
177         this.postTime = postTime;
178     }
179     
180     /**
181      * @roller.wrapPojoMethod type="simple"
182      * @ejb:persistent-field
183      * @hibernate.property column="spam" non-null="false" unique="false"
184      */

185     public Boolean JavaDoc getSpam() {
186         return this.spam;
187     }
188     
189     /** @ejb:persistent-field */
190     public void setSpam(Boolean JavaDoc spam) {
191         this.spam = spam;
192     }
193     
194     /**
195      * @roller.wrapPojoMethod type="simple"
196      * @ejb:persistent-field
197      * @hibernate.property column="notify" non-null="false" unique="false"
198      */

199     public Boolean JavaDoc getNotify() {
200         return this.notify;
201     }
202     
203     /** @ejb:persistent-field */
204     public void setNotify(Boolean JavaDoc notify) {
205         this.notify = notify;
206     }
207     
208     /**
209      * @roller.wrapPojoMethod type="simple"
210      * @ejb:persistent-field
211      * @hibernate.property column="pending" non-null="false" unique="false"
212      */

213     public Boolean JavaDoc getPending() {
214         return this.pending;
215     }
216     
217     /** @ejb:persistent-field */
218     public void setPending(Boolean JavaDoc pending) {
219         this.pending = pending;
220     }
221     
222     /**
223      * @roller.wrapPojoMethod type="simple"
224      * @ejb:persistent-field
225      * @hibernate.property column="approved" non-null="false" unique="false"
226      */

227     public Boolean JavaDoc getApproved() {
228         return this.approved;
229     }
230     
231     /** @ejb:persistent-field */
232     public void setApproved(Boolean JavaDoc approved) {
233         this.approved = approved;
234     }
235     
236     /**
237      * @ejb:persistent-field
238      */

239     public void setRemoteHost(String JavaDoc remoteHost) {
240         this.remoteHost = remoteHost;
241     }
242         
243     /**
244      * @roller.wrapPojoMethod type="simple"
245      * @ejb:persistent-field
246      * @hibernate.property column="remotehost" non-null="true" unique="false"
247      */

248     public String JavaDoc getRemoteHost() {
249         return this.remoteHost;
250     }
251     
252     public String JavaDoc toString() {
253         StringBuffer JavaDoc str = new StringBuffer JavaDoc("{");
254         
255         str.append("id=" + id + " " +
256                 "name=" + name + " " +
257                 "email=" + email + " " +
258                 "url=" + url + " " +
259                 "content=" + content + " " +
260                 "postTime=" + postTime + " " +
261                 "spam=" + spam +
262                 "notify=" + notify +
263                 "pending" + pending +
264                 "approved" + approved);
265         str.append('}');
266         
267         return (str.toString());
268     }
269     
270     public boolean equals(Object JavaDoc pOther) {
271         if (pOther instanceof CommentData) {
272             CommentData lTest = (CommentData) pOther;
273             boolean lEquals = true;
274             
275             lEquals = PojoUtil.equals(lEquals, this.id, lTest.getId());
276             lEquals = PojoUtil.equals(lEquals, this.weblogEntry, lTest.getWeblogEntry());
277             lEquals = PojoUtil.equals(lEquals, this.name, lTest.getName());
278             lEquals = PojoUtil.equals(lEquals, this.email, lTest.getEmail());
279             lEquals = PojoUtil.equals(lEquals, this.url, lTest.getUrl());
280             lEquals = PojoUtil.equals(lEquals, this.content, lTest.getContent());
281             lEquals = PojoUtil.equals(lEquals, this.postTime, lTest.getPostTime());
282             lEquals = PojoUtil.equals(lEquals, this.spam, lTest.getSpam());
283             lEquals = PojoUtil.equals(lEquals, this.notify, lTest.getNotify());
284             lEquals = PojoUtil.equals(lEquals, this.pending, lTest.getPending());
285             lEquals = PojoUtil.equals(lEquals, this.approved, lTest.getApproved());
286             return lEquals;
287         } else {
288             return false;
289         }
290     }
291     
292     public int hashCode() {
293         int result = 17;
294         result = PojoUtil.addHashCode(result, this.id);
295         result = PojoUtil.addHashCode(result, this.weblogEntry);
296         result = PojoUtil.addHashCode(result, this.name);
297         result = PojoUtil.addHashCode(result, this.email);
298         result = PojoUtil.addHashCode(result, this.url);
299         result = PojoUtil.addHashCode(result, this.content);
300         result = PojoUtil.addHashCode(result, this.postTime);
301         result = PojoUtil.addHashCode(result, this.spam);
302         result = PojoUtil.addHashCode(result, this.notify);
303         result = PojoUtil.addHashCode(result, this.pending);
304         result = PojoUtil.addHashCode(result, this.approved);
305         
306         return result;
307     }
308     
309     /**
310      * Setter is needed in RollerImpl.storePersistentObject()
311      */

312     public void setData(org.apache.roller.pojos.PersistentObject otherData) {
313         CommentData otherComment = (CommentData) otherData;
314         
315         this.id = otherComment.getId();
316         this.weblogEntry = otherComment.getWeblogEntry();
317         this.name = otherComment.getName();
318         this.email = otherComment.getEmail();
319         this.url = otherComment.getUrl();
320         this.content = otherComment.getContent();
321         this.postTime = otherComment.getPostTime();
322         this.spam = otherComment.getSpam();
323         this.notify = otherComment.getNotify();
324         this.pending = otherComment.getPending();
325         this.approved = otherComment.getApproved();
326     }
327     
328     /**
329      * Timestamp to be used to formulate comment permlink.
330      * @roller.wrapPojoMethod type="simple"
331      */

332     public String JavaDoc getTimestamp() {
333         if (postTime != null) {
334             return Long.toString(postTime.getTime());
335         }
336         return null;
337     }
338     
339     /** No-op to please XDoclet */
340     public void setTimestamp(String JavaDoc timeStamp) {}
341 }
Popular Tags