001: /*
002: * This program is free software; you can redistribute it and/or modify
003: * it under the terms of the GNU General Public License as published by
004: * the Free Software Foundation; either version 2 of the License, or
005: * (at your option) any later version.
006: *
007: * This program is distributed in the hope that it will be useful,
008: * but WITHOUT ANY WARRANTY; without even the implied warranty of
009: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
010: * GNU Library General Public License for more details.
011: *
012: * You should have received a copy of the GNU General Public License
013: * along with this program; if not, write to the Free Software
014: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
015: */
016: package dlog4j.formbean;
017:
018: import javax.servlet.http.HttpServletRequest;
019:
020: import java.util.List;
021:
022: import org.apache.commons.lang.StringUtils;
023: import org.apache.struts.action.ActionError;
024: import org.apache.struts.action.ActionErrors;
025: import org.apache.struts.action.ActionForm;
026: import org.apache.struts.action.ActionMapping;
027:
028: /**
029: * CategoryForm.java created by EasyStruts - XsltGen.
030: * http://easystruts.sf.net
031: * created on 02-03-2004
032: *
033: * XDoclet definition:
034: * @struts:form name="categoryForm"
035: */
036: public class CategoryForm extends ActionForm {
037:
038: public final static int TYPE_OWNER = 0x00; //只有日记所有者才可以看
039: public final static int TYPE_GENERAL = 0x01; //一般的日记分类
040: public final static int TYPE_COMMON = 0x02; //只要是角色为ROLE_FRIEND的都可以发表日志
041: // --------------------------------------------------------- Instance Variables
042:
043: /** iconUrl property */
044: private String iconUrl;
045:
046: /** type property */
047: private int type;
048:
049: /** order property */
050: private int order = -1;//该初始值请不要修改,用于创建分类时order字段的自动处理
051:
052: /** name property */
053: private String name;
054:
055: /** id property */
056: private int id = -1;
057:
058: /** logs property */
059: private List logs;
060:
061: private SiteForm site;
062:
063: private int logCount = 0;
064:
065: // --------------------------------------------------------- Methods
066: public boolean isCommon() {
067: return type == TYPE_COMMON;
068: }
069:
070: public boolean isOwnerOnly() {
071: return type == TYPE_OWNER;
072: }
073:
074: /**
075: * Method validate
076: * @param ActionMapping mapping
077: * @param HttpServletRequest request
078: * @return ActionErrors
079: */
080: public ActionErrors validate(ActionMapping mapping,
081: HttpServletRequest request) {
082: ActionErrors aes = new ActionErrors();
083: if (type != TYPE_OWNER && type != TYPE_GENERAL
084: && type != TYPE_COMMON)
085: aes
086: .add("edit", new ActionError(
087: "category_type_not_accept"));
088: if (name != null && StringUtils.isEmpty(name))
089: aes.add("edit", new ActionError("not_empty_allow"));
090: return aes;
091: }
092:
093: /**
094: * Returns the iconUrl.
095: * @return String
096: */
097: public String getIconUrl() {
098: return iconUrl;
099: }
100:
101: /**
102: * Set the iconUrl.
103: * @param iconUrl The iconUrl to set
104: */
105: public void setIconUrl(String iconUrl) {
106: if (!"".equals(iconUrl))
107: this .iconUrl = iconUrl;
108: }
109:
110: /**
111: * Returns the type.
112: * @return int
113: */
114: public int getType() {
115: return type;
116: }
117:
118: public String getTypeDesc() {
119: switch (type) {
120: case TYPE_OWNER:
121: return "隐藏分类";
122: case TYPE_GENERAL:
123: return "普通分类";
124: case TYPE_COMMON:
125: return "开放分类";
126: }
127: return null;
128: }
129:
130: /**
131: * Set the type.
132: * @param type The type to set
133: */
134: public void setType(int type) {
135: this .type = type;
136: }
137:
138: /**
139: * Returns the order.
140: * @return int
141: */
142: public int getOrder() {
143: return order;
144: }
145:
146: /**
147: * Set the order.
148: * @param order The order to set
149: */
150: public void setOrder(int order) {
151: this .order = order;
152: }
153:
154: /**
155: * Returns the name.
156: * @return String
157: */
158: public String getName() {
159: return name;
160: }
161:
162: /**
163: * Set the name.
164: * @param name The name to set
165: */
166: public void setName(String name) {
167: this .name = name;
168: }
169:
170: /**
171: * Returns the id.
172: * @return int
173: */
174: public int getId() {
175: return id;
176: }
177:
178: /**
179: * Set the id.
180: * @param id The id to set
181: */
182: public void setId(int id) {
183: this .id = id;
184: }
185:
186: /**
187: * @return
188: */
189: public List getLogs() {
190: return logs;
191: }
192:
193: /**
194: * @param list
195: */
196: public void setLogs(List list) {
197: logs = list;
198: }
199:
200: /* (non-Javadoc)
201: * @see java.lang.Object#toString()
202: */
203: public String toString() {
204: return name;
205: }
206:
207: /**
208: * @return
209: */
210: public SiteForm getSite() {
211: return site;
212: }
213:
214: /**
215: * @param form
216: */
217: public void setSite(SiteForm form) {
218: site = form;
219: }
220:
221: public int getLogCount() {
222: return logCount;
223: }
224:
225: public void setLogCount(int logCount) {
226: this.logCount = logCount;
227: }
228: }
|