KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * $Header: /cvsroot/mvnforum/mvnforum/src/com/mvnforum/db/MessageBean.java,v 1.13 2006/04/14 17:05:26 minhnn Exp $
3  * $Author: minhnn $
4  * $Revision: 1.13 $
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: MessageID, FolderName, MemberID, MessageSenderID, MessageSenderName,
51  * MessageToList, MessageCcList, MessageBccList, MessageTopic, MessageBody,
52  * MessageType, MessageOption, MessageStatus, MessageReadStatus, MessageNotify,
53  * MessageIcon, MessageAttachCount, MessageIP, MessageCreationDate
54  * Excluded columns:
55  */

56 public class MessageBean {
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 means this message has NOT been read
63      */

64     public final static int MESSAGE_READ_STATUS_DEFAULT = 0;
65
66     /**
67      * This value means this message has been read
68      */

69     public final static int MESSAGE_READ_STATUS_READ = 1;
70
71     /**
72      * The default value means this message type is normal
73      */

74     public final static int MESSAGE_TYPE_DEFAULT = 0;
75
76     /**
77      * This value means this message has been mark as Quote [Marco]
78      */

79     public final static int MESSAGE_TYPE_QUOTE = 1;
80
81     /**
82      * This value means this message is a public message
83      */

84     public final static int MESSAGE_TYPE_PUBLIC = 2;
85
86     private int messageID;
87     private String JavaDoc folderName;
88     private int memberID;
89     private int messageSenderID;
90     private String JavaDoc messageSenderName;
91     private String JavaDoc messageToList;
92     private String JavaDoc messageCcList;
93     private String JavaDoc messageBccList;
94     private String JavaDoc messageTopic;
95     private String JavaDoc messageBody;
96     private int messageType;
97     private int messageOption;
98     private int messageStatus;
99     private int messageReadStatus;
100     private int messageNotify;
101     private String JavaDoc messageIcon;
102     private int messageAttachCount;
103     private String JavaDoc messageIP;
104     private Timestamp JavaDoc messageCreationDate;
105
106     public int getMessageID() {
107         return messageID;
108     }
109     public void setMessageID(int messageID) {
110         this.messageID = messageID;
111     }
112
113     public String JavaDoc getFolderName() {
114         return folderName;
115     }
116     public void setFolderName(String JavaDoc folderName) {
117         this.folderName = folderName;
118     }
119
120     public int getMemberID() {
121         return memberID;
122     }
123     public void setMemberID(int memberID) {
124         this.memberID = memberID;
125     }
126
127     public int getMessageSenderID() {
128         return messageSenderID;
129     }
130     public void setMessageSenderID(int messageSenderID) {
131         this.messageSenderID = messageSenderID;
132     }
133
134     public String JavaDoc getMessageSenderName() {
135         return messageSenderName;
136     }
137     public void setMessageSenderName(String JavaDoc messageSenderName) {
138         this.messageSenderName = messageSenderName;
139     }
140
141     public String JavaDoc getMessageToList() {
142         return messageToList;
143     }
144     public void setMessageToList(String JavaDoc messageToList) {
145         this.messageToList = StringUtil.getEmptyStringIfNull(messageToList);
146     }
147
148     public String JavaDoc getMessageCcList() {
149         return messageCcList;
150     }
151     public void setMessageCcList(String JavaDoc messageCcList) {
152         this.messageCcList = StringUtil.getEmptyStringIfNull(messageCcList);
153     }
154
155     public String JavaDoc getMessageBccList() {
156         return messageBccList;
157     }
158     public void setMessageBccList(String JavaDoc messageBccList) {
159         this.messageBccList = StringUtil.getEmptyStringIfNull(messageBccList);
160     }
161
162     public String JavaDoc getMessageTopic() {
163         return messageTopic;
164     }
165     public void setMessageTopic(String JavaDoc messageTopic) {
166         this.messageTopic = StringUtil.getEmptyStringIfNull(messageTopic);
167     }
168
169     public String JavaDoc getMessageBody() {
170         return messageBody;
171     }
172     public void setMessageBody(String JavaDoc messageBody) {
173         this.messageBody = StringUtil.getEmptyStringIfNull(messageBody);
174     }
175
176     public int getMessageType() {
177         return messageType;
178     }
179     public void setMessageType(int messageType) {
180         this.messageType = messageType;
181     }
182
183     public int getMessageOption() {
184         return messageOption;
185     }
186     public void setMessageOption(int messageOption) {
187         this.messageOption = messageOption;
188     }
189
190     public int getMessageStatus() {
191         return messageStatus;
192     }
193     public void setMessageStatus(int messageStatus) {
194         this.messageStatus = messageStatus;
195     }
196
197     public int getMessageReadStatus() {
198         return messageReadStatus;
199     }
200     public void setMessageReadStatus(int messageReadStatus) {
201         this.messageReadStatus = messageReadStatus;
202     }
203
204     public int getMessageNotify() {
205         return messageNotify;
206     }
207     public void setMessageNotify(int messageNotify) {
208         this.messageNotify = messageNotify;
209     }
210
211     public String JavaDoc getMessageIcon() {
212         return messageIcon;
213     }
214     public void setMessageIcon(String JavaDoc messageIcon) {
215         this.messageIcon = StringUtil.getEmptyStringIfNull(messageIcon);
216     }
217
218     public int getMessageAttachCount() {
219         return messageAttachCount;
220     }
221     public void setMessageAttachCount(int messageAttachCount) {
222         this.messageAttachCount = messageAttachCount;
223     }
224
225     public String JavaDoc getMessageIP() {
226         return messageIP;
227     }
228     public void setMessageIP(String JavaDoc messageIP) {
229         this.messageIP = messageIP;
230     }
231
232     public Timestamp JavaDoc getMessageCreationDate() {
233         return messageCreationDate;
234     }
235     public void setMessageCreationDate(Timestamp JavaDoc messageCreationDate) {
236         this.messageCreationDate = messageCreationDate;
237     }
238
239     public String JavaDoc getXML() {
240         StringBuffer JavaDoc xml = new StringBuffer JavaDoc(1024);
241         xml.append("<MessageSection>\n");
242         xml.append(" <Rows>\n");
243         xml.append(" <Row>\n");
244         xml.append(" <Column>\n");
245         xml.append(" <Name>MessageID</Name>\n");
246         xml.append(" <Value>").append(String.valueOf(messageID)).append("</Value>\n");
247         xml.append(" </Column>\n");
248         xml.append(" <Column>\n");
249         xml.append(" <Name>FolderName</Name>\n");
250         xml.append(" <Value>").append(String.valueOf(folderName)).append("</Value>\n");
251         xml.append(" </Column>\n");
252         xml.append(" <Column>\n");
253         xml.append(" <Name>MemberID</Name>\n");
254         xml.append(" <Value>").append(String.valueOf(memberID)).append("</Value>\n");
255         xml.append(" </Column>\n");
256         xml.append(" <Column>\n");
257         xml.append(" <Name>MessageSenderID</Name>\n");
258         xml.append(" <Value>").append(String.valueOf(messageSenderID)).append("</Value>\n");
259         xml.append(" </Column>\n");
260         xml.append(" <Column>\n");
261         xml.append(" <Name>MessageSenderName</Name>\n");
262         xml.append(" <Value>").append(String.valueOf(messageSenderName)).append("</Value>\n");
263         xml.append(" </Column>\n");
264         xml.append(" <Column>\n");
265         xml.append(" <Name>MessageToList</Name>\n");
266         xml.append(" <Value>").append(String.valueOf(messageToList)).append("</Value>\n");
267         xml.append(" </Column>\n");
268         xml.append(" <Column>\n");
269         xml.append(" <Name>MessageCcList</Name>\n");
270         xml.append(" <Value>").append(String.valueOf(messageCcList)).append("</Value>\n");
271         xml.append(" </Column>\n");
272         xml.append(" <Column>\n");
273         xml.append(" <Name>MessageBccList</Name>\n");
274         xml.append(" <Value>").append(String.valueOf(messageBccList)).append("</Value>\n");
275         xml.append(" </Column>\n");
276         xml.append(" <Column>\n");
277         xml.append(" <Name>MessageTopic</Name>\n");
278         xml.append(" <Value>").append(String.valueOf(messageTopic)).append("</Value>\n");
279         xml.append(" </Column>\n");
280         xml.append(" <Column>\n");
281         xml.append(" <Name>MessageBody</Name>\n");
282         xml.append(" <Value>").append(String.valueOf(messageBody)).append("</Value>\n");
283         xml.append(" </Column>\n");
284         xml.append(" <Column>\n");
285         xml.append(" <Name>MessageType</Name>\n");
286         xml.append(" <Value>").append(String.valueOf(messageType)).append("</Value>\n");
287         xml.append(" </Column>\n");
288         xml.append(" <Column>\n");
289         xml.append(" <Name>MessageOption</Name>\n");
290         xml.append(" <Value>").append(String.valueOf(messageOption)).append("</Value>\n");
291         xml.append(" </Column>\n");
292         xml.append(" <Column>\n");
293         xml.append(" <Name>MessageStatus</Name>\n");
294         xml.append(" <Value>").append(String.valueOf(messageStatus)).append("</Value>\n");
295         xml.append(" </Column>\n");
296         xml.append(" <Column>\n");
297         xml.append(" <Name>MessageReadStatus</Name>\n");
298         xml.append(" <Value>").append(String.valueOf(messageReadStatus)).append("</Value>\n");
299         xml.append(" </Column>\n");
300         xml.append(" <Column>\n");
301         xml.append(" <Name>MessageNotify</Name>\n");
302         xml.append(" <Value>").append(String.valueOf(messageNotify)).append("</Value>\n");
303         xml.append(" </Column>\n");
304         xml.append(" <Column>\n");
305         xml.append(" <Name>MessageIcon</Name>\n");
306         xml.append(" <Value>").append(String.valueOf(messageIcon)).append("</Value>\n");
307         xml.append(" </Column>\n");
308         xml.append(" <Column>\n");
309         xml.append(" <Name>MessageAttachCount</Name>\n");
310         xml.append(" <Value>").append(String.valueOf(messageAttachCount)).append("</Value>\n");
311         xml.append(" </Column>\n");
312         xml.append(" <Column>\n");
313         xml.append(" <Name>MessageIP</Name>\n");
314         xml.append(" <Value>").append(String.valueOf(messageIP)).append("</Value>\n");
315         xml.append(" </Column>\n");
316         xml.append(" <Column>\n");
317         xml.append(" <Name>MessageCreationDate</Name>\n");
318         xml.append(" <Value>").append(String.valueOf(messageCreationDate)).append("</Value>\n");
319         xml.append(" </Column>\n");
320         xml.append(" </Row>\n");
321         xml.append(" </Rows>\n");
322         xml.append("</MessageSection>\n");
323         return xml.toString();
324     }
325
326     public static String JavaDoc getXML(Collection JavaDoc objMessageBeans) {
327         StringBuffer JavaDoc xml = new StringBuffer JavaDoc(1024);
328         Iterator JavaDoc iterator = objMessageBeans.iterator();
329         xml.append("<MessageSection>\n");
330         xml.append(" <Rows>\n");
331         while (iterator.hasNext()) {
332             MessageBean objMessageBean = (MessageBean)iterator.next();
333             xml.append(" <Row>\n");
334             xml.append(" <Column>\n");
335             xml.append(" <Name>MessageID</Name>\n");
336             xml.append(" <Value>").append(String.valueOf(objMessageBean.messageID)).append("</Value>\n");
337             xml.append(" </Column>\n");
338             xml.append(" <Column>\n");
339             xml.append(" <Name>FolderName</Name>\n");
340             xml.append(" <Value>").append(String.valueOf(objMessageBean.folderName)).append("</Value>\n");
341             xml.append(" </Column>\n");
342             xml.append(" <Column>\n");
343             xml.append(" <Name>MemberID</Name>\n");
344             xml.append(" <Value>").append(String.valueOf(objMessageBean.memberID)).append("</Value>\n");
345             xml.append(" </Column>\n");
346             xml.append(" <Column>\n");
347             xml.append(" <Name>MessageSenderID</Name>\n");
348             xml.append(" <Value>").append(String.valueOf(objMessageBean.messageSenderID)).append("</Value>\n");
349             xml.append(" </Column>\n");
350             xml.append(" <Column>\n");
351             xml.append(" <Name>MessageSenderName</Name>\n");
352             xml.append(" <Value>").append(String.valueOf(objMessageBean.messageSenderName)).append("</Value>\n");
353             xml.append(" </Column>\n");
354             xml.append(" <Column>\n");
355             xml.append(" <Name>MessageToList</Name>\n");
356             xml.append(" <Value>").append(String.valueOf(objMessageBean.messageToList)).append("</Value>\n");
357             xml.append(" </Column>\n");
358             xml.append(" <Column>\n");
359             xml.append(" <Name>MessageCcList</Name>\n");
360             xml.append(" <Value>").append(String.valueOf(objMessageBean.messageCcList)).append("</Value>\n");
361             xml.append(" </Column>\n");
362             xml.append(" <Column>\n");
363             xml.append(" <Name>MessageBccList</Name>\n");
364             xml.append(" <Value>").append(String.valueOf(objMessageBean.messageBccList)).append("</Value>\n");
365             xml.append(" </Column>\n");
366             xml.append(" <Column>\n");
367             xml.append(" <Name>MessageTopic</Name>\n");
368             xml.append(" <Value>").append(String.valueOf(objMessageBean.messageTopic)).append("</Value>\n");
369             xml.append(" </Column>\n");
370             xml.append(" <Column>\n");
371             xml.append(" <Name>MessageBody</Name>\n");
372             xml.append(" <Value>").append(String.valueOf(objMessageBean.messageBody)).append("</Value>\n");
373             xml.append(" </Column>\n");
374             xml.append(" <Column>\n");
375             xml.append(" <Name>MessageType</Name>\n");
376             xml.append(" <Value>").append(String.valueOf(objMessageBean.messageType)).append("</Value>\n");
377             xml.append(" </Column>\n");
378             xml.append(" <Column>\n");
379             xml.append(" <Name>MessageOption</Name>\n");
380             xml.append(" <Value>").append(String.valueOf(objMessageBean.messageOption)).append("</Value>\n");
381             xml.append(" </Column>\n");
382             xml.append(" <Column>\n");
383             xml.append(" <Name>MessageStatus</Name>\n");
384             xml.append(" <Value>").append(String.valueOf(objMessageBean.messageStatus)).append("</Value>\n");
385             xml.append(" </Column>\n");
386             xml.append(" <Column>\n");
387             xml.append(" <Name>MessageReadStatus</Name>\n");
388             xml.append(" <Value>").append(String.valueOf(objMessageBean.messageReadStatus)).append("</Value>\n");
389             xml.append(" </Column>\n");
390             xml.append(" <Column>\n");
391             xml.append(" <Name>MessageNotify</Name>\n");
392             xml.append(" <Value>").append(String.valueOf(objMessageBean.messageNotify)).append("</Value>\n");
393             xml.append(" </Column>\n");
394             xml.append(" <Column>\n");
395             xml.append(" <Name>MessageIcon</Name>\n");
396             xml.append(" <Value>").append(String.valueOf(objMessageBean.messageIcon)).append("</Value>\n");
397             xml.append(" </Column>\n");
398             xml.append(" <Column>\n");
399             xml.append(" <Name>MessageAttachCount</Name>\n");
400             xml.append(" <Value>").append(String.valueOf(objMessageBean.messageAttachCount)).append("</Value>\n");
401             xml.append(" </Column>\n");
402             xml.append(" <Column>\n");
403             xml.append(" <Name>MessageIP</Name>\n");
404             xml.append(" <Value>").append(String.valueOf(objMessageBean.messageIP)).append("</Value>\n");
405             xml.append(" </Column>\n");
406             xml.append(" <Column>\n");
407             xml.append(" <Name>MessageCreationDate</Name>\n");
408             xml.append(" <Value>").append(String.valueOf(objMessageBean.messageCreationDate)).append("</Value>\n");
409             xml.append(" </Column>\n");
410             xml.append(" </Row>\n");
411         }//while
412
xml.append(" </Rows>\n");
413         xml.append("</MessageSection>\n");
414         return xml.toString();
415     }
416     /************************************************
417      * Customized methods come below
418      ************************************************/

419     private MemberBean memberBean = null;
420     private Collection JavaDoc attachmentBeans = null;
421
422     public MemberBean getMemberBean() {
423         return memberBean;
424     }
425     public void setMemberBean(MemberBean memberBean) {
426         this.memberBean = memberBean;
427     }
428
429     public Collection JavaDoc getAttachmentBeans() {
430         return attachmentBeans;
431     }
432     public void setAttachmentBeans(Collection JavaDoc attachmentBeans) {
433         this.attachmentBeans = attachmentBeans;
434     }
435
436 } //end of class MessageBean
437
Popular Tags