KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * $Header: /cvsroot/mvnforum/mvnforum/src/com/mvnforum/db/GroupsBean.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.exception.ObjectNotFoundException;
48 import net.myvietnam.mvncore.util.StringUtil;
49
50 /*
51  * Included columns: GroupID, GroupOwnerID, GroupOwnerName, GroupName, GroupDesc,
52  * GroupOption, GroupCreationDate, GroupModifiedDate
53  * Excluded columns:
54  */

55 public class GroupsBean {
56
57     private int groupID;
58     private int groupOwnerID;
59     private String JavaDoc groupOwnerName;
60     private String JavaDoc groupName;
61     private String JavaDoc groupDesc;
62     private int groupOption;
63     private Timestamp JavaDoc groupCreationDate;
64     private Timestamp JavaDoc groupModifiedDate;
65
66     public int getGroupID() {
67         return groupID;
68     }
69     public void setGroupID(int groupID) {
70         this.groupID = groupID;
71     }
72
73     public int getGroupOwnerID() {
74         return groupOwnerID;
75     }
76     public void setGroupOwnerID(int groupOwnerID) {
77         this.groupOwnerID = groupOwnerID;
78     }
79
80     public String JavaDoc getGroupOwnerName() {
81         return groupOwnerName;
82     }
83     public void setGroupOwnerName(String JavaDoc groupOwnerName) {
84         this.groupOwnerName = StringUtil.getEmptyStringIfNull(groupOwnerName);
85     }
86
87     public String JavaDoc getGroupName() {
88         return groupName;
89     }
90     public void setGroupName(String JavaDoc groupName) {
91         this.groupName = groupName;
92     }
93
94     public String JavaDoc getGroupDesc() {
95         return groupDesc;
96     }
97     public void setGroupDesc(String JavaDoc groupDesc) {
98         this.groupDesc = StringUtil.getEmptyStringIfNull(groupDesc);
99     }
100
101     public int getGroupOption() {
102         return groupOption;
103     }
104     public void setGroupOption(int groupOption) {
105         this.groupOption = groupOption;
106     }
107
108     public Timestamp JavaDoc getGroupCreationDate() {
109         return groupCreationDate;
110     }
111     public void setGroupCreationDate(Timestamp JavaDoc groupCreationDate) {
112         this.groupCreationDate = groupCreationDate;
113     }
114
115     public Timestamp JavaDoc getGroupModifiedDate() {
116         return groupModifiedDate;
117     }
118     public void setGroupModifiedDate(Timestamp JavaDoc groupModifiedDate) {
119         this.groupModifiedDate = groupModifiedDate;
120     }
121
122     public String JavaDoc getXML() {
123         StringBuffer JavaDoc xml = new StringBuffer JavaDoc(1024);
124         xml.append("<GroupsSection>\n");
125         xml.append(" <Rows>\n");
126         xml.append(" <Row>\n");
127         xml.append(" <Column>\n");
128         xml.append(" <Name>GroupID</Name>\n");
129         xml.append(" <Value>").append(String.valueOf(groupID)).append("</Value>\n");
130         xml.append(" </Column>\n");
131         xml.append(" <Column>\n");
132         xml.append(" <Name>GroupOwnerID</Name>\n");
133         xml.append(" <Value>").append(String.valueOf(groupOwnerID)).append("</Value>\n");
134         xml.append(" </Column>\n");
135         xml.append(" <Column>\n");
136         xml.append(" <Name>GroupOwnerName</Name>\n");
137         xml.append(" <Value>").append(String.valueOf(groupOwnerName)).append("</Value>\n");
138         xml.append(" </Column>\n");
139         xml.append(" <Column>\n");
140         xml.append(" <Name>GroupName</Name>\n");
141         xml.append(" <Value>").append(String.valueOf(groupName)).append("</Value>\n");
142         xml.append(" </Column>\n");
143         xml.append(" <Column>\n");
144         xml.append(" <Name>GroupDesc</Name>\n");
145         xml.append(" <Value>").append(String.valueOf(groupDesc)).append("</Value>\n");
146         xml.append(" </Column>\n");
147         xml.append(" <Column>\n");
148         xml.append(" <Name>GroupOption</Name>\n");
149         xml.append(" <Value>").append(String.valueOf(groupOption)).append("</Value>\n");
150         xml.append(" </Column>\n");
151         xml.append(" <Column>\n");
152         xml.append(" <Name>GroupCreationDate</Name>\n");
153         xml.append(" <Value>").append(String.valueOf(groupCreationDate)).append("</Value>\n");
154         xml.append(" </Column>\n");
155         xml.append(" <Column>\n");
156         xml.append(" <Name>GroupModifiedDate</Name>\n");
157         xml.append(" <Value>").append(String.valueOf(groupModifiedDate)).append("</Value>\n");
158         xml.append(" </Column>\n");
159         xml.append(" </Row>\n");
160         xml.append(" </Rows>\n");
161         xml.append("</GroupsSection>\n");
162         return xml.toString();
163     }
164
165     public static String JavaDoc getXML(Collection JavaDoc objGroupsBeans) {
166         StringBuffer JavaDoc xml = new StringBuffer JavaDoc(1024);
167         Iterator JavaDoc iterator = objGroupsBeans.iterator();
168         xml.append("<GroupsSection>\n");
169         xml.append(" <Rows>\n");
170         while (iterator.hasNext()) {
171             GroupsBean objGroupsBean = (GroupsBean)iterator.next();
172             xml.append(" <Row>\n");
173             xml.append(" <Column>\n");
174             xml.append(" <Name>GroupID</Name>\n");
175             xml.append(" <Value>").append(String.valueOf(objGroupsBean.groupID)).append("</Value>\n");
176             xml.append(" </Column>\n");
177             xml.append(" <Column>\n");
178             xml.append(" <Name>GroupOwnerID</Name>\n");
179             xml.append(" <Value>").append(String.valueOf(objGroupsBean.groupOwnerID)).append("</Value>\n");
180             xml.append(" </Column>\n");
181             xml.append(" <Column>\n");
182             xml.append(" <Name>GroupOwnerName</Name>\n");
183             xml.append(" <Value>").append(String.valueOf(objGroupsBean.groupOwnerName)).append("</Value>\n");
184             xml.append(" </Column>\n");
185             xml.append(" <Column>\n");
186             xml.append(" <Name>GroupName</Name>\n");
187             xml.append(" <Value>").append(String.valueOf(objGroupsBean.groupName)).append("</Value>\n");
188             xml.append(" </Column>\n");
189             xml.append(" <Column>\n");
190             xml.append(" <Name>GroupDesc</Name>\n");
191             xml.append(" <Value>").append(String.valueOf(objGroupsBean.groupDesc)).append("</Value>\n");
192             xml.append(" </Column>\n");
193             xml.append(" <Column>\n");
194             xml.append(" <Name>GroupOption</Name>\n");
195             xml.append(" <Value>").append(String.valueOf(objGroupsBean.groupOption)).append("</Value>\n");
196             xml.append(" </Column>\n");
197             xml.append(" <Column>\n");
198             xml.append(" <Name>GroupCreationDate</Name>\n");
199             xml.append(" <Value>").append(String.valueOf(objGroupsBean.groupCreationDate)).append("</Value>\n");
200             xml.append(" </Column>\n");
201             xml.append(" <Column>\n");
202             xml.append(" <Name>GroupModifiedDate</Name>\n");
203             xml.append(" <Value>").append(String.valueOf(objGroupsBean.groupModifiedDate)).append("</Value>\n");
204             xml.append(" </Column>\n");
205             xml.append(" </Row>\n");
206         }//while
207
xml.append(" </Rows>\n");
208         xml.append("</GroupsSection>\n");
209         return xml.toString();
210     }
211
212     /************************************************
213      * Customized methods come below
214      ************************************************/

215     private int groupMemberCount;
216
217     public int getGroupMemberCount() {
218         return groupMemberCount;
219     }
220     public void setGroupMemberCount(int groupMemberCount) {
221         this.groupMemberCount = groupMemberCount;
222     }
223
224     public static GroupsBean getGroupsBean(Collection JavaDoc objGroupsBeans, int groupID)
225         throws ObjectNotFoundException {
226         Iterator JavaDoc iterator = objGroupsBeans.iterator();
227         while (iterator.hasNext()) {
228             GroupsBean objGroupsBean = (GroupsBean)iterator.next();
229             if (objGroupsBean.getGroupID() == groupID) {
230                 return objGroupsBean;
231             }
232         }//while
233
//@todo : localize me
234
throw new ObjectNotFoundException("Cannot find GroupsBean with GroupID = " + groupID);
235     }
236
237 } //end of class GroupsBean
238
Popular Tags