KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > dlog4j > formbean > CategoryForm


1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 2 of the License, or
5  * (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU Library General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software
14  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15  */

16 package dlog4j.formbean;
17
18 import javax.servlet.http.HttpServletRequest JavaDoc;
19
20 import java.util.List JavaDoc;
21
22 import org.apache.commons.lang.StringUtils;
23 import org.apache.struts.action.ActionError;
24 import org.apache.struts.action.ActionErrors;
25 import org.apache.struts.action.ActionForm;
26 import org.apache.struts.action.ActionMapping;
27
28 /**
29  * CategoryForm.java created by EasyStruts - XsltGen.
30  * http://easystruts.sf.net
31  * created on 02-03-2004
32  *
33  * XDoclet definition:
34  * @struts:form name="categoryForm"
35  */

36 public class CategoryForm extends ActionForm {
37
38     public final static int TYPE_OWNER = 0x00; //只有日记所有者才可以看
39
public final static int TYPE_GENERAL = 0x01; //一般的日记分类
40
public final static int TYPE_COMMON = 0x02; //只要是角色为ROLE_FRIEND的都可以发表日志
41
// --------------------------------------------------------- Instance Variables
42

43     /** iconUrl property */
44     private String JavaDoc iconUrl;
45
46     /** type property */
47     private int type;
48
49     /** order property */
50     private int order = -1;//该初始值请不要修改,用于创建分类时order字段的自动处理
51

52     /** name property */
53     private String JavaDoc name;
54
55     /** id property */
56     private int id = -1;
57     
58     /** logs property */
59     private List JavaDoc logs;
60     
61     private SiteForm site;
62     
63     private int logCount = 0;
64
65     // --------------------------------------------------------- Methods
66
public boolean isCommon(){
67         return type == TYPE_COMMON;
68     }
69     public boolean isOwnerOnly(){
70         return type == TYPE_OWNER;
71     }
72     /**
73      * Method validate
74      * @param ActionMapping mapping
75      * @param HttpServletRequest request
76      * @return ActionErrors
77      */

78     public ActionErrors validate(
79         ActionMapping mapping,
80         HttpServletRequest JavaDoc request) {
81         ActionErrors aes = new ActionErrors();
82         if(type!=TYPE_OWNER&&type!=TYPE_GENERAL&&type!=TYPE_COMMON)
83             aes.add("edit",new ActionError("category_type_not_accept"));
84         if(name!=null && StringUtils.isEmpty(name))
85             aes.add("edit",new ActionError("not_empty_allow"));
86         return aes;
87     }
88
89     /**
90      * Returns the iconUrl.
91      * @return String
92      */

93     public String JavaDoc getIconUrl() {
94         return iconUrl;
95     }
96
97     /**
98      * Set the iconUrl.
99      * @param iconUrl The iconUrl to set
100      */

101     public void setIconUrl(String JavaDoc iconUrl) {
102         if(!"".equals(iconUrl))
103             this.iconUrl = iconUrl;
104     }
105
106     /**
107      * Returns the type.
108      * @return int
109      */

110     public int getType() {
111         return type;
112     }
113     
114     public String JavaDoc getTypeDesc() {
115         switch(type) {
116         case TYPE_OWNER:
117             return "隐藏分类";
118         case TYPE_GENERAL:
119             return "普通分类";
120         case TYPE_COMMON:
121             return "开放分类";
122         }
123         return null;
124     }
125
126     /**
127      * Set the type.
128      * @param type The type to set
129      */

130     public void setType(int type) {
131         this.type = type;
132     }
133
134     /**
135      * Returns the order.
136      * @return int
137      */

138     public int getOrder() {
139         return order;
140     }
141
142     /**
143      * Set the order.
144      * @param order The order to set
145      */

146     public void setOrder(int order) {
147         this.order = order;
148     }
149
150     /**
151      * Returns the name.
152      * @return String
153      */

154     public String JavaDoc getName() {
155         return name;
156     }
157
158     /**
159      * Set the name.
160      * @param name The name to set
161      */

162     public void setName(String JavaDoc name) {
163         this.name = name;
164     }
165
166     /**
167      * Returns the id.
168      * @return int
169      */

170     public int getId() {
171         return id;
172     }
173
174     /**
175      * Set the id.
176      * @param id The id to set
177      */

178     public void setId(int id) {
179         this.id = id;
180     }
181
182     /**
183      * @return
184      */

185     public List JavaDoc getLogs() {
186         return logs;
187     }
188
189     /**
190      * @param list
191      */

192     public void setLogs(List JavaDoc list) {
193         logs = list;
194     }
195
196     /* (non-Javadoc)
197      * @see java.lang.Object#toString()
198      */

199     public String JavaDoc toString() {
200         return name;
201     }
202
203     /**
204      * @return
205      */

206     public SiteForm getSite() {
207         return site;
208     }
209
210     /**
211      * @param form
212      */

213     public void setSite(SiteForm form) {
214         site = form;
215     }
216
217     public int getLogCount() {
218         return logCount;
219     }
220     public void setLogCount(int logCount) {
221         this.logCount = logCount;
222     }
223 }
224
Popular Tags