KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > dlog4j > formbean > ParamForm


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 org.apache.commons.lang.StringUtils;
21 import org.apache.struts.action.ActionError;
22 import org.apache.struts.action.ActionErrors;
23 import org.apache.struts.action.ActionMapping;
24
25 /**
26  * @author Liudong
27  * 系统参数对象
28  */

29 public class ParamForm extends DlogActionForm {
30     
31     public final static int TYPE_INTEGER = 0x01;
32     public final static int TYPE_STRING = 0x02;
33     public final static int TYPE_BOOLEAN = 0x03;
34     public final static int TYPE_DATE = 0x04;
35     public final static int TYPE_TIME = 0x08;
36     public final static int TYPE_DATETIME= 0x10;
37     
38     private int id;
39     private String JavaDoc name;
40     private int type;
41     private String JavaDoc value;
42     private String JavaDoc desc;
43     
44     private SiteForm site;
45
46     /* (non-Javadoc)
47      * @see org.apache.struts.action.ActionForm#validate(org.apache.struts.action.ActionMapping, javax.servlet.http.HttpServletRequest)
48      */

49     public ActionErrors validate(ActionMapping mapping, HttpServletRequest JavaDoc req) {
50         ActionErrors es = new ActionErrors();
51         if(type==TYPE_INTEGER && !StringUtils.isNumeric(value))
52             es.add("value",new ActionError("illegal_input_value"));
53         return es;
54     }
55     /**
56      * @return
57      */

58     public String JavaDoc getName() {
59         return name;
60     }
61
62     /**
63      * @return
64      */

65     public int getType() {
66         return type;
67     }
68     
69     public String JavaDoc getTypeDesc() {
70         switch(type) {
71         case TYPE_INTEGER:
72             return "INTEGER";
73         case TYPE_STRING:
74             return "STRING";
75         case TYPE_BOOLEAN:
76             return "BOOLEAN";
77         case TYPE_DATE:
78             return "DATE";
79         case TYPE_TIME:
80             return "TIME";
81         case TYPE_DATETIME:
82             return "DATETIME";
83         }
84         return "UNKNOWN";
85     }
86
87     /**
88      * @return
89      */

90     public String JavaDoc getValue() {
91         return value;
92     }
93
94     /**
95      * @param string
96      */

97     public void setName(String JavaDoc string) {
98         name = string;
99     }
100
101     /**
102      * @param i
103      */

104     public void setType(int i) {
105         type = i;
106     }
107
108     /**
109      * @param string
110      */

111     public void setValue(String JavaDoc string) {
112         value = string;
113     }
114
115
116     /**
117      * @return
118      */

119     public String JavaDoc getDesc() {
120         return desc;
121     }
122
123     /**
124      * @param string
125      */

126     public void setDesc(String JavaDoc string) {
127         desc = string;
128     }
129
130     /**
131      * @return
132      */

133     public SiteForm getSite() {
134         return site;
135     }
136
137     /**
138      * @param form
139      */

140     public void setSite(SiteForm form) {
141         site = form;
142     }
143
144     /**
145      * @return
146      */

147     public int getId() {
148         return id;
149     }
150
151     /**
152      * @param i
153      */

154     public void setId(int i) {
155         id = i;
156     }
157
158 }
159
Popular Tags