KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > validator > Var


1 /*
2  * $Id: Var.java 155434 2005-02-26 13:16:41Z dirkv $
3  * $Rev$
4  * $Date: 2005-02-26 05:16:41 -0800 (Sat, 26 Feb 2005) $
5  *
6  * ====================================================================
7  * Copyright 2001-2005 The Apache Software Foundation
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  */

21
22 package org.apache.commons.validator;
23
24 import java.io.Serializable JavaDoc;
25
26 /**
27  * A variable that can be associated with a <code>Field</code> for
28  * passing in information to a pluggable validator. Instances of this class are
29  * configured with a &lt;var&gt; xml element.
30  */

31 public class Var implements Cloneable JavaDoc, Serializable JavaDoc {
32
33     /**
34      * Int Constant for JavaScript type. This can be used
35      * when auto-generating JavaScript.
36      */

37     public static final String JavaDoc JSTYPE_INT = "int";
38
39     /**
40      * String Constant for JavaScript type. This can be used
41      * when auto-generating JavaScript.
42      */

43     public static final String JavaDoc JSTYPE_STRING = "string";
44
45     /**
46      * Regular Expression Constant for JavaScript type. This can be used
47      * when auto-generating JavaScript.
48      */

49     public static final String JavaDoc JSTYPE_REGEXP = "regexp";
50
51     /**
52      * The name of the variable.
53      */

54     private String JavaDoc name = null;
55
56     /**
57      * The name of the value.
58      */

59     private String JavaDoc value = null;
60
61     /**
62      * The optional JavaScript type of the variable.
63      */

64     private String JavaDoc jsType = null;
65
66     public Var() {
67         super();
68     }
69
70     public Var(String JavaDoc name, String JavaDoc value, String JavaDoc jsType) {
71         this.name = name;
72         this.value = value;
73         this.jsType = jsType;
74     }
75
76     /**
77      * Gets the name of the variable.
78      */

79     public String JavaDoc getName() {
80         return this.name;
81     }
82
83     /**
84      * Sets the name of the variable.
85      */

86     public void setName(String JavaDoc name) {
87         this.name = name;
88     }
89
90     /**
91      * Gets the value of the variable.
92      */

93     public String JavaDoc getValue() {
94         return this.value;
95     }
96
97     /**
98      * Sets the value of the variable.
99      */

100     public void setValue(String JavaDoc value) {
101         this.value = value;
102     }
103
104     /**
105      * Gets the JavaScript type of the variable.
106      */

107     public String JavaDoc getJsType() {
108         return this.jsType;
109     }
110
111     /**
112      * Sets the JavaScript type of the variable.
113      */

114     public void setJsType(String JavaDoc jsType) {
115         this.jsType = jsType;
116     }
117
118     /**
119      * Creates and returns a copy of this object.
120      */

121     public Object JavaDoc clone() {
122         try {
123             return super.clone();
124
125         } catch(CloneNotSupportedException JavaDoc e) {
126             throw new RuntimeException JavaDoc(e.toString());
127         }
128     }
129
130     /**
131      * Returns a string representation of the object.
132      */

133     public String JavaDoc toString() {
134         StringBuffer JavaDoc results = new StringBuffer JavaDoc();
135
136         results.append("Var: name=");
137         results.append(name);
138         results.append(" value=");
139         results.append(value);
140         results.append(" jsType=");
141         results.append(jsType);
142         results.append("\n");
143
144         return results.toString();
145     }
146
147 }
Popular Tags