Coverage report

| %line | %branch
--- | --- | ---
org.apache.commons.validator.Arg |
47% |
100% |

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 |  |
      * <p>
23 |  |
      * A default argument or an argument for a
24 |  |
      * specific validator definition (ex: required)
25 |  |
      * can be stored to pass into a message as parameters.  This can be used in a
26 |  |
      * pluggable validator for constructing locale
27 |  |
      * sensitive messages by using <code>java.text.MessageFormat</code>
28 |  |
      * or an equivalent class.  The resource field can be
29 |  |
      * used to determine if the value stored in the argument
30 |  |
      * is a value to be retrieved from a locale sensitive
31 |  |
      * message retrieval system like <code>java.util.PropertyResourceBundle</code>.
32 |  |
      * The resource field defaults to 'true'.
33 |  |
      * </p>
34 |  |
      * <p>Instances of this class are configured with an &lt;arg&gt; xml element.</p>
35 |  |
      *
36 |  |
      * @version $Revision: 478334 $ $Date: 2006-11-22 21:31:54 +0000 (Wed, 22 Nov 2006) $
37 |  |
      */
38 | 278 |
     public class Arg implements Cloneable, Serializable {
39 |  |
40 |  |
         /**
41 |  |
          * The resource bundle name that this Arg's <code>key</code> should be
42 |  |
          * resolved in (optional).
43 |  |
          * @since Validator 1.1
44 |  |
          */
45 | 139 |
         protected String bundle = null;
46 |  |
47 |  |
         /**
48 |  |
          * The key or value of the argument.
49 |  |
          */
50 | 139 |
         protected String key = null;
51 |  |
52 |  |
         /**
53 |  |
          * The name dependency that this argument goes with (optional).
54 |  |
          */
55 | 139 |
         protected String name = null;
56 |  |
57 |  |
         /**
58 |  |
          * This argument's position in the message. Set postion=0 to
59 |  |
          * make a replacement in this string: "some msg {0}".
60 |  |
          * @since Validator 1.1
61 |  |
          */
62 | 139 |
         protected int position = -1;
63 |  |
64 |  |
         /**
65 |  |
          * Whether or not the key is a message resource (optional).  Defaults to
66 |  |
          * true.  If it is 'true', the value will try to be resolved as a message
67 |  |
          * resource.
68 |  |
          */
69 | 139 |
         protected boolean resource = true;
70 |  |
71 |  |
         /**
72 |  |
          * Creates and returns a copy of this object.
73 |  |
          * @return A copy of this object.
74 |  |
          */
75 |  |
         public Object clone() {
76 |  |
             try {
77 | 0 |
                 return super.clone();
78 |  |
79 |  |
             } catch(CloneNotSupportedException e) {
80 | 0 |
                 throw new RuntimeException(e.toString());
81 |  |
             }
82 |  |
         }
83 |  |
84 |  |
         /**
85 |  |
          * Returns the resource bundle name.
86 |  |
          * @return the bundle name.
87 |  |
          * @since Validator 1.1
88 |  |
          */
89 |  |
         public String getBundle() {
90 | 0 |
             return this.bundle;
91 |  |
         }
92 |  |
93 |  |
         /**
94 |  |
          * Gets the key/value.
95 |  |
          * @return the key value.
96 |  |
          */
97 |  |
         public String getKey() {
98 | 358 |
             return this.key;
99 |  |
         }
100 |  |
101 |  |
         /**
102 |  |
          * Gets the name of the dependency.
103 |  |
          * @return the name of the dependency.
104 |  |
          */
105 |  |
         public String getName() {
106 | 169 |
             return this.name;
107 |  |
         }
108 |  |
109 |  |
         /**
110 |  |
          * Argument's replacement position.
111 |  |
          * @return This argument's replacement position.
112 |  |
          */
113 |  |
         public int getPosition() {
114 | 680 |
             return this.position;
115 |  |
         }
116 |  |
117 |  |
         /**
118 |  |
          * Tests whether or not the key is a resource key or literal value.
119 |  |
          * @return <code>true</code> if key is a resource key.
120 |  |
          */
121 |  |
         public boolean isResource() {
122 | 0 |
             return this.resource;
123 |  |
         }
124 |  |
125 |  |
         /**
126 |  |
          * Sets the resource bundle name.
127 |  |
          * @param bundle The new bundle name.
128 |  |
          * @since Validator 1.1
129 |  |
          */
130 |  |
         public void setBundle(String bundle) {
131 | 6 |
             this.bundle = bundle;
132 | 6 |
         }
133 |  |
134 |  |
         /**
135 |  |
          * Sets the key/value.
136 |  |
          * @param key They to access the argument.
137 |  |
          */
138 |  |
         public void setKey(String key) {
139 | 179 |
             this.key = key;
140 | 179 |
         }
141 |  |
142 |  |
         /**
143 |  |
          * Sets the name of the dependency.
144 |  |
          * @param name the name of the dependency.
145 |  |
          */
146 |  |
         public void setName(String name) {
147 | 9 |
             this.name = name;
148 | 9 |
         }
149 |  |
150 |  |
         /**
151 |  |
          * Set this argument's replacement position.
152 |  |
          * @param position set this argument's replacement position.
153 |  |
          */
154 |  |
         public void setPosition(int position) {
155 | 139 |
             this.position = position;
156 | 139 |
         }
157 |  |
158 |  |
         /**
159 |  |
          * Sets whether or not the key is a resource.
160 |  |
          * @param resource If true indicates the key is a resource.
161 |  |
          */
162 |  |
         public void setResource(boolean resource) {
163 | 0 |
             this.resource = resource;
164 | 0 |
         }
165 |  |
166 |  |
         /**
167 |  |
          * Returns a string representation of the object.
168 |  |
          * @return a string representation of the object.
169 |  |
          */
170 |  |
         public String toString() {
171 | 0 |
             StringBuffer results = new StringBuffer();
172 |  |
173 | 0 |
             results.append("Arg: name=");
174 | 0 |
             results.append(name);
175 | 0 |
             results.append("  key=");
176 | 0 |
             results.append(key);
177 | 0 |
             results.append("  position=");
178 | 0 |
             results.append(position);
179 | 0 |
             results.append("  bundle=");
180 | 0 |
             results.append(bundle);
181 | 0 |
             results.append("  resource=");
182 | 0 |
             results.append(resource);
183 | 0 |
             results.append("\n");
184 |  |
185 | 0 |
             return results.toString();
186 |  |
         }
187 |  |
188 |  |
     }

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