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 org.apache.commons.lang.StringUtils;
021: import org.apache.struts.action.ActionError;
022: import org.apache.struts.action.ActionErrors;
023: import org.apache.struts.action.ActionMapping;
024:
025: /**
026: * @author Liudong
027: * 系统参数对象
028: */
029: public class ParamForm extends DlogActionForm {
030:
031: public final static int TYPE_INTEGER = 0x01;
032: public final static int TYPE_STRING = 0x02;
033: public final static int TYPE_BOOLEAN = 0x03;
034: public final static int TYPE_DATE = 0x04;
035: public final static int TYPE_TIME = 0x08;
036: public final static int TYPE_DATETIME = 0x10;
037:
038: private int id;
039: private String name;
040: private int type;
041: private String value;
042: private String desc;
043:
044: private SiteForm site;
045:
046: /* (non-Javadoc)
047: * @see org.apache.struts.action.ActionForm#validate(org.apache.struts.action.ActionMapping, javax.servlet.http.HttpServletRequest)
048: */
049: public ActionErrors validate(ActionMapping mapping,
050: HttpServletRequest req) {
051: ActionErrors es = new ActionErrors();
052: if (type == TYPE_INTEGER && !StringUtils.isNumeric(value))
053: es.add("value", new ActionError("illegal_input_value"));
054: return es;
055: }
056:
057: /**
058: * @return
059: */
060: public String getName() {
061: return name;
062: }
063:
064: /**
065: * @return
066: */
067: public int getType() {
068: return type;
069: }
070:
071: public String getTypeDesc() {
072: switch (type) {
073: case TYPE_INTEGER:
074: return "INTEGER";
075: case TYPE_STRING:
076: return "STRING";
077: case TYPE_BOOLEAN:
078: return "BOOLEAN";
079: case TYPE_DATE:
080: return "DATE";
081: case TYPE_TIME:
082: return "TIME";
083: case TYPE_DATETIME:
084: return "DATETIME";
085: }
086: return "UNKNOWN";
087: }
088:
089: /**
090: * @return
091: */
092: public String getValue() {
093: return value;
094: }
095:
096: /**
097: * @param string
098: */
099: public void setName(String string) {
100: name = string;
101: }
102:
103: /**
104: * @param i
105: */
106: public void setType(int i) {
107: type = i;
108: }
109:
110: /**
111: * @param string
112: */
113: public void setValue(String string) {
114: value = string;
115: }
116:
117: /**
118: * @return
119: */
120: public String getDesc() {
121: return desc;
122: }
123:
124: /**
125: * @param string
126: */
127: public void setDesc(String string) {
128: desc = string;
129: }
130:
131: /**
132: * @return
133: */
134: public SiteForm getSite() {
135: return site;
136: }
137:
138: /**
139: * @param form
140: */
141: public void setSite(SiteForm form) {
142: site = form;
143: }
144:
145: /**
146: * @return
147: */
148: public int getId() {
149: return id;
150: }
151:
152: /**
153: * @param i
154: */
155: public void setId(int i) {
156: id = i;
157: }
158:
159: }
|