Coverage report

| %line | %branch
--- | --- | ---
org.apache.commons.validator.Var |
51% |
93% |

1 |  |
     /*
2 |  |
      * Licensed to the Apache Software Foundation (ASF) under one or more
3 |  |
      * contributor license agreements.  See the NOTICE file distributed with
4 |  |
      * this work for additional information regarding copyright ownership.
5 |  |
      * The ASF licenses this file to You under the Apache License, Version 2.0
6 |  |
      * (the "License"); you may not use this file except in compliance with
7 |  |
      * the License.  You may obtain a copy of the License at
8 |  |
      *
9 |  |
      *      http://www.apache.org/licenses/LICENSE-2.0
10 |  |
      *
11 |  |
      * Unless required by applicable law or agreed to in writing, software
12 |  |
      * distributed under the License is distributed on an "AS IS" BASIS,
13 |  |
      * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 |  |
      * See the License for the specific language governing permissions and
15 |  |
      * limitations under the License.
16 |  |
      */
17 |  |
     package org.apache.commons.validator;
18 |  |
19 |  |
     import java.io.Serializable;
20 |  |
21 |  |
     /**
22 |  |
      * A variable that can be associated with a <code>Field</code> for
23 |  |
      * passing in information to a pluggable validator.  Instances of this class are
24 |  |
      * configured with a &lt;var&gt; xml element.
25 |  |
      *
26 |  |
      * @version $Revision: 478334 $ $Date: 2006-11-22 21:31:54 +0000 (Wed, 22 Nov 2006) $
27 |  |
      */
28 |  |
     public class Var implements Cloneable, Serializable {
29 |  |
30 |  |
         /**
31 |  |
          * Int Constant for JavaScript type.  This can be used
32 |  |
          * when auto-generating JavaScript.
33 |  |
          */
34 |  |
         public static final String JSTYPE_INT = "int";
35 |  |
36 |  |
         /**
37 |  |
          * String Constant for JavaScript type.  This can be used
38 |  |
          * when auto-generating JavaScript.
39 |  |
          */
40 |  |
         public static final String JSTYPE_STRING = "string";
41 |  |
42 |  |
         /**
43 |  |
          * Regular Expression Constant for JavaScript type.  This can be used
44 |  |
          * when auto-generating JavaScript.
45 |  |
          */
46 |  |
         public static final String JSTYPE_REGEXP = "regexp";
47 |  |
48 |  |
         /**
49 |  |
          * The name of the variable.
50 |  |
          */
51 | 125 |
         private String name = null;
52 |  |
53 |  |
         /**
54 |  |
          * The key or value the variable.
55 |  |
          */
56 | 125 |
         private String value = null;
57 |  |
58 |  |
         /**
59 |  |
          * The optional JavaScript type of the variable.
60 |  |
          */
61 | 125 |
         private String jsType = null;
62 |  |
63 |  |
         /**
64 |  |
          * Whether the variable is a resource [false]
65 |  |
          */
66 | 125 |
         private boolean resource = false;
67 |  |
68 |  |
         /**
69 |  |
          * The bundle for a variable (when resource = 'true').
70 |  |
          */
71 | 125 |
         private String bundle = null;
72 |  |
73 |  |
         /**
74 |  |
          * Default Constructor.
75 |  |
          */
76 |  |
         public Var() {
77 | 125 |
             super();
78 | 125 |
         }
79 |  |
80 |  |
         /**
81 |  |
          * Constructs a variable with a specified name, value
82 |  |
          * and Javascript type.
83 |  |
          * @param name Variable name.
84 |  |
          * @param value Variable value.
85 |  |
          * @param jsType Variable Javascript type.
86 |  |
          */
87 | 0 |
         public Var(String name, String value, String jsType) {
88 | 0 |
             this.name = name;
89 | 0 |
             this.value = value;
90 | 0 |
             this.jsType = jsType;
91 | 0 |
         }
92 |  |
93 |  |
         /**
94 |  |
          * Gets the name of the variable.
95 |  |
          * @return The name of the variable.
96 |  |
          */
97 |  |
         public String getName() {
98 | 128 |
             return this.name;
99 |  |
         }
100 |  |
101 |  |
         /**
102 |  |
          * Sets the name of the variable.
103 |  |
          * @param name The name of the variable.
104 |  |
          */
105 |  |
         public void setName(String name) {
106 | 125 |
             this.name = name;
107 | 125 |
         }
108 |  |
109 |  |
         /**
110 |  |
          * Gets the value of the variable.
111 |  |
          * @return The value of the variable.
112 |  |
          */
113 |  |
         public String getValue() {
114 | 272 |
             return this.value;
115 |  |
         }
116 |  |
117 |  |
         /**
118 |  |
          * Sets the value of the variable.
119 |  |
          * @param value The value of the variable.
120 |  |
          */
121 |  |
         public void setValue(String value) {
122 | 205 |
             this.value = value;
123 | 205 |
         }
124 |  |
125 |  |
         /**
126 |  |
          * Tests whether or not the value is a resource key or literal value.
127 |  |
          * @return <code>true</code> if value is a resource key.
128 |  |
          * @since Validator 1.2.0
129 |  |
          */
130 |  |
         public boolean isResource() {
131 | 3 |
             return this.resource;
132 |  |
         }
133 |  |
134 |  |
         /**
135 |  |
          * Sets whether or not the value is a resource.
136 |  |
          * @param resource If true indicates the value is a resource.
137 |  |
          * @since Validator 1.2.0
138 |  |
          */
139 |  |
         public void setResource(boolean resource) {
140 | 2 |
             this.resource = resource;
141 | 2 |
         }
142 |  |
143 |  |
         /**
144 |  |
          * Returns the resource bundle name.
145 |  |
          * @return The bundle name.
146 |  |
          * @since Validator 1.2.0
147 |  |
          */
148 |  |
         public String getBundle() {
149 | 3 |
             return this.bundle;
150 |  |
         }
151 |  |
152 |  |
         /**
153 |  |
          * Sets the resource bundle name.
154 |  |
          * @param bundle The new bundle name.
155 |  |
          * @since Validator 1.2.0
156 |  |
          */
157 |  |
         public void setBundle(String bundle) {
158 | 2 |
             this.bundle = bundle;
159 | 2 |
         }
160 |  |
161 |  |
         /**
162 |  |
          * Gets the JavaScript type of the variable.
163 |  |
          * @return The Javascript type of the variable.
164 |  |
          */
165 |  |
         public String getJsType() {
166 | 3 |
             return this.jsType;
167 |  |
         }
168 |  |
169 |  |
         /**
170 |  |
          * Sets the JavaScript type of the variable.
171 |  |
          * @param jsType The Javascript type of the variable.
172 |  |
          */
173 |  |
         public void setJsType(String jsType) {
174 | 2 |
             this.jsType = jsType;
175 | 2 |
         }
176 |  |
177 |  |
         /**
178 |  |
          * Creates and returns a copy of this object.
179 |  |
          * @return A copy of the variable.
180 |  |
          */
181 |  |
         public Object clone() {
182 |  |
             try {
183 | 0 |
                 return super.clone();
184 |  |
185 |  |
             } catch(CloneNotSupportedException e) {
186 | 0 |
                 throw new RuntimeException(e.toString());
187 |  |
             }
188 |  |
         }
189 |  |
190 |  |
         /**
191 |  |
          * Returns a string representation of the object.
192 |  |
          * @return A string representation of the variable.
193 |  |
          */
194 |  |
         public String toString() {
195 | 0 |
             StringBuffer results = new StringBuffer();
196 |  |
197 | 0 |
             results.append("Var: name=");
198 | 0 |
             results.append(name);
199 | 0 |
             results.append("  value=");
200 | 0 |
             results.append(value);
201 | 0 |
             results.append("  resource=");
202 | 0 |
             results.append(resource);
203 | 0 |
             if (resource) {
204 | 0 |
                 results.append("  bundle=");
205 | 0 |
                 results.append(bundle);
206 |  |
             }
207 | 0 |
             results.append("  jsType=");
208 | 0 |
             results.append(jsType);
209 | 0 |
             results.append("\n");
210 |  |
211 | 0 |
             return results.toString();
212 |  |
         }
213 |  |
214 |  |
     }

This report is generated by jcoverage, Maven and Maven JCoverage Plugin.