001: /*
002: * $Header: /cvsroot/mvnforum/mvnforum/contrib/phpbb2mvnforum/src/org/mvnforum/phpbb2mvnforum/db/CategoryBean.java,v 1.3 2007/01/15 10:27:34 dungbtm Exp $
003: * $Author: dungbtm $
004: * $Revision: 1.3 $
005: * $Date: 2007/01/15 10:27:34 $
006: *
007: * ====================================================================
008: *
009: * Copyright (C) 2002-2007 by MyVietnam.net
010: *
011: * All copyright notices regarding mvnForum MUST remain
012: * intact in the scripts and in the outputted HTML.
013: * The "powered by" text/logo with a link back to
014: * http://www.mvnForum.com and http://www.MyVietnam.net in
015: * the footer of the pages MUST remain visible when the pages
016: * are viewed on the internet or intranet.
017: *
018: * This program is free software; you can redistribute it and/or modify
019: * it under the terms of the GNU General Public License as published by
020: * the Free Software Foundation; either version 2 of the License, or
021: * any later version.
022: *
023: * This program is distributed in the hope that it will be useful,
024: * but WITHOUT ANY WARRANTY; without even the implied warranty of
025: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
026: * GNU General Public License for more details.
027: *
028: * You should have received a copy of the GNU General Public License
029: * along with this program; if not, write to the Free Software
030: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
031: *
032: * Support can be obtained from support forums at:
033: * http://www.mvnForum.com/mvnforum/index
034: *
035: * Correspondence and Marketing Questions can be sent to:
036: * info at MyVietnam net
037: *
038: * @author: Minh Nguyen
039: * @author: Mai Nguyen
040: */
041: package org.mvnforum.phpbb2mvnforum.db;
042:
043: import java.sql.Timestamp;
044: import java.util.Collection;
045: import java.util.Iterator;
046:
047: import org.w3c.dom.Document;
048: import org.w3c.dom.Element;
049: import org.w3c.dom.Node;
050:
051: import net.myvietnam.mvncore.util.StringUtil;
052:
053: /*
054: * Included columns: CategoryID, ParentCategoryID, CategoryName, CategoryDesc, CategoryCreationDate,
055: * CategoryModifiedDate, CategoryOrder, CategoryOption, CategoryStatus
056: * Excluded columns:
057: */
058: public class CategoryBean {
059: private int categoryID;
060: private int parentCategoryID;
061: private String categoryName;
062: private String categoryDesc;
063: private Timestamp categoryCreationDate;
064: private Timestamp categoryModifiedDate;
065: private int categoryOrder;
066: private int categoryOption;
067: private int categoryStatus;
068:
069: public int getCategoryID() {
070: return categoryID;
071: }
072:
073: public void setCategoryID(int categoryID) {
074: this .categoryID = categoryID;
075: }
076:
077: public int getParentCategoryID() {
078: return parentCategoryID;
079: }
080:
081: public void setParentCategoryID(int parentCategoryID) {
082: this .parentCategoryID = parentCategoryID;
083: }
084:
085: public String getCategoryName() {
086: return categoryName;
087: }
088:
089: public void setCategoryName(String categoryName) {
090: this .categoryName = categoryName;
091: }
092:
093: public String getCategoryDesc() {
094: return categoryDesc;
095: }
096:
097: public void setCategoryDesc(String categoryDesc) {
098: this .categoryDesc = StringUtil
099: .getEmptyStringIfNull(categoryDesc);
100: }
101:
102: public Timestamp getCategoryCreationDate() {
103: return categoryCreationDate;
104: }
105:
106: public void setCategoryCreationDate(Timestamp categoryCreationDate) {
107: this .categoryCreationDate = categoryCreationDate;
108: }
109:
110: public Timestamp getCategoryModifiedDate() {
111: return categoryModifiedDate;
112: }
113:
114: public void setCategoryModifiedDate(Timestamp categoryModifiedDate) {
115: this .categoryModifiedDate = categoryModifiedDate;
116: }
117:
118: public int getCategoryOrder() {
119: return categoryOrder;
120: }
121:
122: public void setCategoryOrder(int categoryOrder) {
123: this .categoryOrder = categoryOrder;
124: }
125:
126: public int getCategoryOption() {
127: return categoryOption;
128: }
129:
130: public void setCategoryOption(int categoryOption) {
131: this .categoryOption = categoryOption;
132: }
133:
134: public int getCategoryStatus() {
135: return categoryStatus;
136: }
137:
138: public void setCategoryStatus(int categoryStatus) {
139: this .categoryStatus = categoryStatus;
140: }
141:
142: public String getXMLTag() {
143: StringBuffer xml = new StringBuffer(1024);
144: xml.append("<Category");
145: xml.append(" categoryID=\"").append(String.valueOf(categoryID))
146: .append("\"");
147: xml.append(" parentCategoryID=\"").append(
148: String.valueOf(parentCategoryID)).append("\"");
149: xml.append(" categoryName=\"").append(
150: String.valueOf(categoryName)).append("\"");
151: xml.append(" categoryDesc=\"").append(
152: String.valueOf(categoryDesc)).append("\"");
153: xml.append(" categoryCreationDate=\"").append(
154: String.valueOf(categoryCreationDate)).append("\"");
155: xml.append(" categoryModifiedDate=\"").append(
156: String.valueOf(categoryModifiedDate)).append("\"");
157: xml.append(" categoryOrder=\"").append(
158: String.valueOf(categoryOrder)).append("\"");
159: xml.append(" categoryOption=\"").append(
160: String.valueOf(categoryOption)).append("\"");
161: xml.append(" categoryStatus=\"").append(
162: String.valueOf(categoryStatus)).append("\"");
163: xml.append(">");
164: return xml.toString();
165: }
166:
167: public void getBeanDocument(Document doc, Element element) {
168: Element category = doc.createElement("Category");
169: element.appendChild(category);
170:
171: category.appendChild(getNode(doc, "CategoryID", String
172: .valueOf(categoryID)));
173: category.appendChild(getNode(doc, "ParentCategoryID", String
174: .valueOf(parentCategoryID)));
175: category.appendChild(getNode(doc, "CategoryName", String
176: .valueOf(categoryName)));
177: category.appendChild(getNode(doc, "CategoryDesc", String
178: .valueOf(categoryDesc)));
179: category.appendChild(getNode(doc, "CategoryModifiedDate",
180: String.valueOf(categoryModifiedDate)));
181: category.appendChild(getNode(doc, "CategoryCreationDate",
182: String.valueOf(categoryCreationDate)));
183: category.appendChild(getNode(doc, "CategoryOrder", String
184: .valueOf(categoryOrder)));
185: category.appendChild(getNode(doc, "CategoryOption", String
186: .valueOf(categoryOption)));
187: category.appendChild(getNode(doc, "CategoryStatus", String
188: .valueOf(categoryStatus)));
189: }
190:
191: public static Node getNode(Document doc, String childName,
192: String childValue) {
193: Element child = doc.createElement(childName);
194: child.appendChild(doc.createTextNode(childValue));
195: return child;
196: }
197:
198: public String getXML() {
199: StringBuffer xml = new StringBuffer(1024);
200: xml.append("<Category>\n");
201:
202: xml.append("<CategoryID>" + categoryID + "</CategoryID>\n");
203: xml.append("<ParentCategoryID>" + parentCategoryID
204: + "</ParentCategoryID>\n");
205: xml.append("<CategoryName>" + categoryName
206: + "</CategoryName>\n");
207: xml.append("<CategoryDesc>" + categoryDesc
208: + "</CategoryDesc>\n");
209: xml.append("<CategoryCreationDate>" + categoryCreationDate
210: + "</CategoryCreationDate>\n");
211: xml.append("<CategoryModifiedDate>" + categoryModifiedDate
212: + "</CategoryModifiedDate>\n");
213: xml.append("<CategoryModifiedDate>" + categoryModifiedDate
214: + "</CategoryModifiedDate>\n");
215: xml.append("<CategoryOrder>" + categoryOrder
216: + "</CategoryOrder>\n");
217: xml.append("<CategoryOption>" + categoryOption
218: + "</CategoryOption>\n");
219: xml.append("<CategoryStatus>" + categoryStatus
220: + "</CategoryStatus>\n");
221:
222: xml.append("</Category>\n");
223: return xml.toString();
224: }
225:
226: public static String getXML(Collection beans) {
227: StringBuffer xml = new StringBuffer(1024);
228: xml.append("<CategoryList>");
229:
230: for (Iterator iter = beans.iterator(); iter.hasNext();) {
231: CategoryBean bean = (CategoryBean) iter.next();
232: xml.append(bean.getXML());
233: }
234: xml.append("</CategoryList>");
235: return xml.toString();
236: }
237:
238: /*public static String getXML(Collection objCategoryBeans) {
239: StringBuffer xml = new StringBuffer(1024);
240: Iterator iterator = objCategoryBeans.iterator();
241: xml.append("<CategorySection>\n");
242: xml.append(" <Rows>\n");
243: while (iterator.hasNext()) {
244: CategoryBean objCategoryBean = (CategoryBean)iterator.next();
245: xml.append(" <Row>\n");
246: xml.append(" <Column>\n");
247: xml.append(" <Name>CategoryID</Name>\n");
248: xml.append(" <Value>").append(String.valueOf(objCategoryBean.categoryID)).append("</Value>\n");
249: xml.append(" </Column>\n");
250: xml.append(" <Column>\n");
251: xml.append(" <Name>ParentCategoryID</Name>\n");
252: xml.append(" <Value>").append(String.valueOf(objCategoryBean.parentCategoryID)).append("</Value>\n");
253: xml.append(" </Column>\n");
254: xml.append(" <Column>\n");
255: xml.append(" <Name>CategoryName</Name>\n");
256: xml.append(" <Value>").append(String.valueOf(objCategoryBean.categoryName)).append("</Value>\n");
257: xml.append(" </Column>\n");
258: xml.append(" <Column>\n");
259: xml.append(" <Name>CategoryDesc</Name>\n");
260: xml.append(" <Value>").append(String.valueOf(objCategoryBean.categoryDesc)).append("</Value>\n");
261: xml.append(" </Column>\n");
262: xml.append(" <Column>\n");
263: xml.append(" <Name>CategoryCreationDate</Name>\n");
264: xml.append(" <Value>").append(String.valueOf(objCategoryBean.categoryCreationDate)).append("</Value>\n");
265: xml.append(" </Column>\n");
266: xml.append(" <Column>\n");
267: xml.append(" <Name>CategoryModifiedDate</Name>\n");
268: xml.append(" <Value>").append(String.valueOf(objCategoryBean.categoryModifiedDate)).append("</Value>\n");
269: xml.append(" </Column>\n");
270: xml.append(" <Column>\n");
271: xml.append(" <Name>CategoryOrder</Name>\n");
272: xml.append(" <Value>").append(String.valueOf(objCategoryBean.categoryOrder)).append("</Value>\n");
273: xml.append(" </Column>\n");
274: xml.append(" <Column>\n");
275: xml.append(" <Name>CategoryOption</Name>\n");
276: xml.append(" <Value>").append(String.valueOf(objCategoryBean.categoryOption)).append("</Value>\n");
277: xml.append(" </Column>\n");
278: xml.append(" <Column>\n");
279: xml.append(" <Name>CategoryStatus</Name>\n");
280: xml.append(" <Value>").append(String.valueOf(objCategoryBean.categoryStatus)).append("</Value>\n");
281: xml.append(" </Column>\n");
282: xml.append(" </Row>\n");
283: }//while
284: xml.append(" </Rows>\n");
285: xml.append("</CategorySection>\n");
286: return xml.toString();
287: }*/
288: } //end of class CategoryBean
|