KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > mvnforum > db > PostBean


1 /*
2  * $Header: /cvsroot/mvnforum/mvnforum/src/com/mvnforum/db/PostBean.java,v 1.8 2006/04/14 17:05:26 minhnn Exp $
3  * $Author: minhnn $
4  * $Revision: 1.8 $
5  * $Date: 2006/04/14 17:05:26 $
6  *
7  * ====================================================================
8  *
9  * Copyright (C) 2002-2006 by MyVietnam.net
10  *
11  * All copyright notices regarding mvnForum MUST remain
12  * intact in the scripts and in the outputted HTML.
13  * The "powered by" text/logo with a link back to
14  * http://www.mvnForum.com and http://www.MyVietnam.net in
15  * the footer of the pages MUST remain visible when the pages
16  * are viewed on the internet or intranet.
17  *
18  * This program is free software; you can redistribute it and/or modify
19  * it under the terms of the GNU General Public License as published by
20  * the Free Software Foundation; either version 2 of the License, or
21  * any later version.
22  *
23  * This program is distributed in the hope that it will be useful,
24  * but WITHOUT ANY WARRANTY; without even the implied warranty of
25  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26  * GNU General Public License for more details.
27  *
28  * You should have received a copy of the GNU General Public License
29  * along with this program; if not, write to the Free Software
30  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
31  *
32  * Support can be obtained from support forums at:
33  * http://www.mvnForum.com/mvnforum/index
34  *
35  * Correspondence and Marketing Questions can be sent to:
36  * info at MyVietnam net
37  *
38  * @author: Minh Nguyen
39  * @author: Mai Nguyen
40  */

41 package com.mvnforum.db;
42
43 import java.sql.Timestamp JavaDoc;
44 import java.util.Collection JavaDoc;
45 import java.util.Iterator JavaDoc;
46
47 import net.myvietnam.mvncore.util.StringUtil;
48
49 /*
50  * Included columns: PostID, ParentPostID, ForumID, ThreadID, MemberID,
51  * MemberName, LastEditMemberName, PostTopic, PostBody, PostCreationDate,
52  * PostLastEditDate, PostCreationIP, PostLastEditIP, PostEditCount, PostFormatOption,
53  * PostOption, PostStatus, PostIcon, PostAttachCount
54  * Excluded columns:
55  */

56 public class PostBean {
57     /*************************************************************************
58      * NOTE: below constants MUST NOT be changed IN ALL CASES,
59      * or it will break the compatibility
60      *************************************************************************/

61     /**
62      * The default value mean post is enable and normal
63      */

64     public final static int POST_STATUS_DEFAULT = 0;
65
66     /**
67      * The disable post is invisible for normal user and visible to moderator
68      */

69     public final static int POST_STATUS_DISABLED = 1;
70
71     private int postID;
72     private int parentPostID;
73     private int forumID;
74     private int threadID;
75     private int memberID;
76     private String JavaDoc memberName;
77     private String JavaDoc lastEditMemberName;
78     private String JavaDoc postTopic;
79     private String JavaDoc postBody;
80     private Timestamp JavaDoc postCreationDate;
81     private Timestamp JavaDoc postLastEditDate;
82     private String JavaDoc postCreationIP;
83     private String JavaDoc postLastEditIP;
84     private int postEditCount;
85     private int postFormatOption;
86     private int postOption;
87     private int postStatus;
88     private String JavaDoc postIcon;
89     private int postAttachCount;
90
91     public int getPostID() {
92         return postID;
93     }
94     public void setPostID(int postID) {
95         this.postID = postID;
96     }
97
98     public int getParentPostID() {
99         return parentPostID;
100     }
101     public void setParentPostID(int parentPostID) {
102         this.parentPostID = parentPostID;
103     }
104
105     public int getForumID() {
106         return forumID;
107     }
108     public void setForumID(int forumID) {
109         this.forumID = forumID;
110     }
111
112     public int getThreadID() {
113         return threadID;
114     }
115     public void setThreadID(int threadID) {
116         this.threadID = threadID;
117     }
118
119     public int getMemberID() {
120         return memberID;
121     }
122     public void setMemberID(int memberID) {
123         this.memberID = memberID;
124     }
125
126     public String JavaDoc getMemberName() {
127         return memberName;
128     }
129     public void setMemberName(String JavaDoc memberName) {
130         this.memberName = memberName;
131     }
132
133     public String JavaDoc getLastEditMemberName() {
134         return lastEditMemberName;
135     }
136     public void setLastEditMemberName(String JavaDoc lastEditMemberName) {
137         this.lastEditMemberName = StringUtil.getEmptyStringIfNull(lastEditMemberName);
138     }
139
140     public String JavaDoc getPostTopic() {
141         return postTopic;
142     }
143     public void setPostTopic(String JavaDoc postTopic) {
144         this.postTopic = postTopic;
145     }
146
147     public String JavaDoc getPostBody() {
148         return postBody;
149     }
150     public void setPostBody(String JavaDoc postBody) {
151         this.postBody = postBody;
152     }
153
154     public Timestamp JavaDoc getPostCreationDate() {
155         return postCreationDate;
156     }
157     public void setPostCreationDate(Timestamp JavaDoc postCreationDate) {
158         this.postCreationDate = postCreationDate;
159     }
160
161     public Timestamp JavaDoc getPostLastEditDate() {
162         return postLastEditDate;
163     }
164     public void setPostLastEditDate(Timestamp JavaDoc postLastEditDate) {
165         this.postLastEditDate = postLastEditDate;
166     }
167
168     public String JavaDoc getPostCreationIP() {
169         return postCreationIP;
170     }
171     public void setPostCreationIP(String JavaDoc postCreationIP) {
172         this.postCreationIP = postCreationIP;
173     }
174
175     public String JavaDoc getPostLastEditIP() {
176         return postLastEditIP;
177     }
178     public void setPostLastEditIP(String JavaDoc postLastEditIP) {
179         this.postLastEditIP = StringUtil.getEmptyStringIfNull(postLastEditIP);
180     }
181
182     public int getPostEditCount() {
183         return postEditCount;
184     }
185     public void setPostEditCount(int postEditCount) {
186         this.postEditCount = postEditCount;
187     }
188
189     public int getPostFormatOption() {
190         return postFormatOption;
191     }
192     public void setPostFormatOption(int postFormatOption) {
193         this.postFormatOption = postFormatOption;
194     }
195
196     public int getPostOption() {
197         return postOption;
198     }
199     public void setPostOption(int postOption) {
200         this.postOption = postOption;
201     }
202
203     public int getPostStatus() {
204         return postStatus;
205     }
206     public void setPostStatus(int postStatus) {
207         this.postStatus = postStatus;
208     }
209
210     public String JavaDoc getPostIcon() {
211         return postIcon;
212     }
213     public void setPostIcon(String JavaDoc postIcon) {
214         this.postIcon = StringUtil.getEmptyStringIfNull(postIcon);
215     }
216
217     public int getPostAttachCount() {
218         return postAttachCount;
219     }
220     public void setPostAttachCount(int postAttachCount) {
221         this.postAttachCount = postAttachCount;
222     }
223
224     public String JavaDoc getXMLTag() {
225         StringBuffer JavaDoc xml = new StringBuffer JavaDoc(1024);
226         xml.append("<Post");
227         xml.append(" postID=\"").append(String.valueOf(postID)).append("\"");
228         xml.append(" parentPostID=\"").append(String.valueOf(parentPostID)).append("\"");
229         xml.append(" forumID=\"").append(String.valueOf(forumID)).append("\"");
230         xml.append(" threadID=\"").append(String.valueOf(threadID)).append("\"");
231         xml.append(" memberID=\"").append(String.valueOf(memberID)).append("\"");
232         xml.append(" memberName=\"").append(String.valueOf(memberName)).append("\"");
233         xml.append(" lastEditMemberName=\"").append(String.valueOf(lastEditMemberName)).append("\"");
234         xml.append(" postTopic=\"").append(String.valueOf(postTopic)).append("\"");
235         xml.append(" postBody=\"").append(String.valueOf(postBody)).append("\"");
236         xml.append(" postCreationDate=\"").append(String.valueOf(postCreationDate)).append("\"");
237         xml.append(" postLastEditDate=\"").append(String.valueOf(postLastEditDate)).append("\"");
238         xml.append(" postCreationIP=\"").append(String.valueOf(postCreationIP)).append("\"");
239         xml.append(" postLastEditIP=\"").append(String.valueOf(postLastEditIP)).append("\"");
240         xml.append(" postEditCount=\"").append(String.valueOf(postEditCount)).append("\"");
241         xml.append(" postFormatOption=\"").append(String.valueOf(postFormatOption)).append("\"");
242         xml.append(" postOption=\"").append(String.valueOf(postOption)).append("\"");
243         xml.append(" postStatus=\"").append(String.valueOf(postStatus)).append("\"");
244         xml.append(" postIcon=\"").append(String.valueOf(postIcon)).append("\"");
245         xml.append(" postAttachCount=\"").append(String.valueOf(postAttachCount)).append("\"");
246         xml.append(">");
247         return xml.toString();
248     }
249
250     public String JavaDoc getXML() {
251         StringBuffer JavaDoc xml = new StringBuffer JavaDoc(1024);
252         xml.append("<PostSection>\n");
253         xml.append(" <Rows>\n");
254         xml.append(" <Row>\n");
255         xml.append(" <Column>\n");
256         xml.append(" <Name>PostID</Name>\n");
257         xml.append(" <Value>").append(String.valueOf(postID)).append("</Value>\n");
258         xml.append(" </Column>\n");
259         xml.append(" <Column>\n");
260         xml.append(" <Name>ParentPostID</Name>\n");
261         xml.append(" <Value>").append(String.valueOf(parentPostID)).append("</Value>\n");
262         xml.append(" </Column>\n");
263         xml.append(" <Column>\n");
264         xml.append(" <Name>ForumID</Name>\n");
265         xml.append(" <Value>").append(String.valueOf(forumID)).append("</Value>\n");
266         xml.append(" </Column>\n");
267         xml.append(" <Column>\n");
268         xml.append(" <Name>ThreadID</Name>\n");
269         xml.append(" <Value>").append(String.valueOf(threadID)).append("</Value>\n");
270         xml.append(" </Column>\n");
271         xml.append(" <Column>\n");
272         xml.append(" <Name>MemberID</Name>\n");
273         xml.append(" <Value>").append(String.valueOf(memberID)).append("</Value>\n");
274         xml.append(" </Column>\n");
275         xml.append(" <Column>\n");
276         xml.append(" <Name>MemberName</Name>\n");
277         xml.append(" <Value>").append(String.valueOf(memberName)).append("</Value>\n");
278         xml.append(" </Column>\n");
279         xml.append(" <Column>\n");
280         xml.append(" <Name>LastEditMemberName</Name>\n");
281         xml.append(" <Value>").append(String.valueOf(lastEditMemberName)).append("</Value>\n");
282         xml.append(" </Column>\n");
283         xml.append(" <Column>\n");
284         xml.append(" <Name>PostTopic</Name>\n");
285         xml.append(" <Value>").append(String.valueOf(postTopic)).append("</Value>\n");
286         xml.append(" </Column>\n");
287         xml.append(" <Column>\n");
288         xml.append(" <Name>PostBody</Name>\n");
289         xml.append(" <Value>").append(String.valueOf(postBody)).append("</Value>\n");
290         xml.append(" </Column>\n");
291         xml.append(" <Column>\n");
292         xml.append(" <Name>PostCreationDate</Name>\n");
293         xml.append(" <Value>").append(String.valueOf(postCreationDate)).append("</Value>\n");
294         xml.append(" </Column>\n");
295         xml.append(" <Column>\n");
296         xml.append(" <Name>PostLastEditDate</Name>\n");
297         xml.append(" <Value>").append(String.valueOf(postLastEditDate)).append("</Value>\n");
298         xml.append(" </Column>\n");
299         xml.append(" <Column>\n");
300         xml.append(" <Name>PostCreationIP</Name>\n");
301         xml.append(" <Value>").append(String.valueOf(postCreationIP)).append("</Value>\n");
302         xml.append(" </Column>\n");
303         xml.append(" <Column>\n");
304         xml.append(" <Name>PostLastEditIP</Name>\n");
305         xml.append(" <Value>").append(String.valueOf(postLastEditIP)).append("</Value>\n");
306         xml.append(" </Column>\n");
307         xml.append(" <Column>\n");
308         xml.append(" <Name>PostEditCount</Name>\n");
309         xml.append(" <Value>").append(String.valueOf(postEditCount)).append("</Value>\n");
310         xml.append(" </Column>\n");
311         xml.append(" <Column>\n");
312         xml.append(" <Name>PostFormatOption</Name>\n");
313         xml.append(" <Value>").append(String.valueOf(postFormatOption)).append("</Value>\n");
314         xml.append(" </Column>\n");
315         xml.append(" <Column>\n");
316         xml.append(" <Name>PostOption</Name>\n");
317         xml.append(" <Value>").append(String.valueOf(postOption)).append("</Value>\n");
318         xml.append(" </Column>\n");
319         xml.append(" <Column>\n");
320         xml.append(" <Name>PostStatus</Name>\n");
321         xml.append(" <Value>").append(String.valueOf(postStatus)).append("</Value>\n");
322         xml.append(" </Column>\n");
323         xml.append(" <Column>\n");
324         xml.append(" <Name>PostIcon</Name>\n");
325         xml.append(" <Value>").append(String.valueOf(postIcon)).append("</Value>\n");
326         xml.append(" </Column>\n");
327         xml.append(" <Column>\n");
328         xml.append(" <Name>PostAttachCount</Name>\n");
329         xml.append(" <Value>").append(String.valueOf(postAttachCount)).append("</Value>\n");
330         xml.append(" </Column>\n");
331         xml.append(" </Row>\n");
332         xml.append(" </Rows>\n");
333         xml.append("</PostSection>\n");
334         return xml.toString();
335     }
336
337     public static String JavaDoc getXML(Collection JavaDoc objPostBeans) {
338         StringBuffer JavaDoc xml = new StringBuffer JavaDoc(1024);
339         Iterator JavaDoc iterator = objPostBeans.iterator();
340         xml.append("<PostSection>\n");
341         xml.append(" <Rows>\n");
342         while (iterator.hasNext()) {
343             PostBean objPostBean = (PostBean)iterator.next();
344             xml.append(" <Row>\n");
345             xml.append(" <Column>\n");
346             xml.append(" <Name>PostID</Name>\n");
347             xml.append(" <Value>").append(String.valueOf(objPostBean.postID)).append("</Value>\n");
348             xml.append(" </Column>\n");
349             xml.append(" <Column>\n");
350             xml.append(" <Name>ParentPostID</Name>\n");
351             xml.append(" <Value>").append(String.valueOf(objPostBean.parentPostID)).append("</Value>\n");
352             xml.append(" </Column>\n");
353             xml.append(" <Column>\n");
354             xml.append(" <Name>ForumID</Name>\n");
355             xml.append(" <Value>").append(String.valueOf(objPostBean.forumID)).append("</Value>\n");
356             xml.append(" </Column>\n");
357             xml.append(" <Column>\n");
358             xml.append(" <Name>ThreadID</Name>\n");
359             xml.append(" <Value>").append(String.valueOf(objPostBean.threadID)).append("</Value>\n");
360             xml.append(" </Column>\n");
361             xml.append(" <Column>\n");
362             xml.append(" <Name>MemberID</Name>\n");
363             xml.append(" <Value>").append(String.valueOf(objPostBean.memberID)).append("</Value>\n");
364             xml.append(" </Column>\n");
365             xml.append(" <Column>\n");
366             xml.append(" <Name>MemberName</Name>\n");
367             xml.append(" <Value>").append(String.valueOf(objPostBean.memberName)).append("</Value>\n");
368             xml.append(" </Column>\n");
369             xml.append(" <Column>\n");
370             xml.append(" <Name>LastEditMemberName</Name>\n");
371             xml.append(" <Value>").append(String.valueOf(objPostBean.lastEditMemberName)).append("</Value>\n");
372             xml.append(" </Column>\n");
373             xml.append(" <Column>\n");
374             xml.append(" <Name>PostTopic</Name>\n");
375             xml.append(" <Value>").append(String.valueOf(objPostBean.postTopic)).append("</Value>\n");
376             xml.append(" </Column>\n");
377             xml.append(" <Column>\n");
378             xml.append(" <Name>PostBody</Name>\n");
379             xml.append(" <Value>").append(String.valueOf(objPostBean.postBody)).append("</Value>\n");
380             xml.append(" </Column>\n");
381             xml.append(" <Column>\n");
382             xml.append(" <Name>PostCreationDate</Name>\n");
383             xml.append(" <Value>").append(String.valueOf(objPostBean.postCreationDate)).append("</Value>\n");
384             xml.append(" </Column>\n");
385             xml.append(" <Column>\n");
386             xml.append(" <Name>PostLastEditDate</Name>\n");
387             xml.append(" <Value>").append(String.valueOf(objPostBean.postLastEditDate)).append("</Value>\n");
388             xml.append(" </Column>\n");
389             xml.append(" <Column>\n");
390             xml.append(" <Name>PostCreationIP</Name>\n");
391             xml.append(" <Value>").append(String.valueOf(objPostBean.postCreationIP)).append("</Value>\n");
392             xml.append(" </Column>\n");
393             xml.append(" <Column>\n");
394             xml.append(" <Name>PostLastEditIP</Name>\n");
395             xml.append(" <Value>").append(String.valueOf(objPostBean.postLastEditIP)).append("</Value>\n");
396             xml.append(" </Column>\n");
397             xml.append(" <Column>\n");
398             xml.append(" <Name>PostEditCount</Name>\n");
399             xml.append(" <Value>").append(String.valueOf(objPostBean.postEditCount)).append("</Value>\n");
400             xml.append(" </Column>\n");
401             xml.append(" <Column>\n");
402             xml.append(" <Name>PostFormatOption</Name>\n");
403             xml.append(" <Value>").append(String.valueOf(objPostBean.postFormatOption)).append("</Value>\n");
404             xml.append(" </Column>\n");
405             xml.append(" <Column>\n");
406             xml.append(" <Name>PostOption</Name>\n");
407             xml.append(" <Value>").append(String.valueOf(objPostBean.postOption)).append("</Value>\n");
408             xml.append(" </Column>\n");
409             xml.append(" <Column>\n");
410             xml.append(" <Name>PostStatus</Name>\n");
411             xml.append(" <Value>").append(String.valueOf(objPostBean.postStatus)).append("</Value>\n");
412             xml.append(" </Column>\n");
413             xml.append(" <Column>\n");
414             xml.append(" <Name>PostIcon</Name>\n");
415             xml.append(" <Value>").append(String.valueOf(objPostBean.postIcon)).append("</Value>\n");
416             xml.append(" </Column>\n");
417             xml.append(" <Column>\n");
418             xml.append(" <Name>PostAttachCount</Name>\n");
419             xml.append(" <Value>").append(String.valueOf(objPostBean.postAttachCount)).append("</Value>\n");
420             xml.append(" </Column>\n");
421             xml.append(" </Row>\n");
422         }//while
423
xml.append(" </Rows>\n");
424         xml.append("</PostSection>\n");
425         return xml.toString();
426     }
427     /************************************************
428      * Customized methods come below
429      ************************************************/

430     private MemberBean memberBean = null;
431     private Collection JavaDoc attachmentBeans = null;
432
433     public MemberBean getMemberBean() {
434         return memberBean;
435     }
436     public void setMemberBean(MemberBean memberBean) {
437         this.memberBean = memberBean;
438     }
439
440     public Collection JavaDoc getAttachmentBeans() {
441         return attachmentBeans;
442     }
443     public void setAttachmentBeans(Collection JavaDoc attachmentBeans) {
444         this.attachmentBeans = attachmentBeans;
445     }
446
447 } //end of class PostBean
448
Popular Tags