KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * $Id: Field.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 import java.lang.reflect.InvocationTargetException JavaDoc;
26 import java.util.ArrayList JavaDoc;
27 import java.util.Collection JavaDoc;
28 import java.util.Collections JavaDoc;
29 import java.util.HashMap JavaDoc;
30 import java.util.Iterator JavaDoc;
31 import java.util.List JavaDoc;
32 import java.util.Map JavaDoc;
33 import java.util.StringTokenizer JavaDoc;
34
35 import org.apache.commons.beanutils.PropertyUtils;
36 import org.apache.commons.collections.FastHashMap; // DEPRECATED
37
import org.apache.commons.validator.util.ValidatorUtils;
38
39 /**
40  * This contains the list of pluggable validators to run on a field and any
41  * message information and variables to perform the validations and generate
42  * error messages. Instances of this class are configured with a
43  * <field> xml element.
44  * <p>
45  * The use of FastHashMap is deprecated and will be replaced in a future
46  * release.
47  * </p>
48  * @see org.apache.commons.validator.Form
49  */

50 public class Field implements Cloneable JavaDoc, Serializable JavaDoc {
51
52     /**
53      * This is the value that will be used as a key if the <code>Arg</code>
54      * name field has no value.
55      */

56     private static final String JavaDoc DEFAULT_ARG =
57             "org.apache.commons.validator.Field.DEFAULT";
58
59     /**
60      * This indicates an indexed property is being referenced.
61      */

62     public static final String JavaDoc TOKEN_INDEXED = "[]";
63
64     protected static final String JavaDoc TOKEN_START = "${";
65     protected static final String JavaDoc TOKEN_END = "}";
66     protected static final String JavaDoc TOKEN_VAR = "var:";
67
68     protected String JavaDoc property = null;
69     protected String JavaDoc indexedProperty = null;
70     protected String JavaDoc indexedListProperty = null;
71     protected String JavaDoc key = null;
72
73     /**
74      * A comma separated list of validator's this field depends on.
75      */

76     protected String JavaDoc depends = null;
77
78     protected int page = 0;
79     
80     protected int fieldOrder = 0;
81
82     /**
83      * Internal representation of this.depends String as a List. This List
84      * gets updated whenever setDepends() gets called. This List is
85      * synchronized so a call to setDepends() (which clears the List) won't
86      * interfere with a call to isDependency().
87      */

88     private List JavaDoc dependencyList = Collections.synchronizedList(new ArrayList JavaDoc());
89
90     /**
91      * @deprecated Subclasses should use getVarMap() instead.
92      */

93     protected FastHashMap hVars = new FastHashMap();
94
95     /**
96      * @deprecated Subclasses should use getMsgMap() instead.
97      */

98     protected FastHashMap hMsgs = new FastHashMap();
99
100     /**
101      * Holds Maps of arguments. args[0] returns the Map for the first
102      * replacement argument. Start with a 0 length array so that it will
103      * only grow to the size of the highest argument position.
104      * @since Validator 1.1
105      */

106     protected Map JavaDoc[] args = new Map JavaDoc[0];
107
108     /**
109      * Gets the page value that the Field is associated with for
110      * validation.
111      */

112     public int getPage() {
113         return this.page;
114     }
115
116     /**
117      * Sets the page value that the Field is associated with for
118      * validation.
119      */

120     public void setPage(int page) {
121         this.page = page;
122     }
123
124     /**
125      * Gets the position of the <code>Field</code> in the validation list.
126      */

127     public int getFieldOrder() {
128         return this.fieldOrder;
129     }
130
131     /**
132      * Sets the position of the <code>Field</code> in the validation list.
133      */

134     public void setFieldOrder(int fieldOrder) {
135         this.fieldOrder = fieldOrder;
136     }
137
138     /**
139      * Gets the property name of the field.
140      */

141     public String JavaDoc getProperty() {
142         return this.property;
143     }
144
145     /**
146      * Sets the property name of the field.
147      */

148     public void setProperty(String JavaDoc property) {
149         this.property = property;
150     }
151
152     /**
153      * Gets the indexed property name of the field. This
154      * is the method name that can take an <code>int</code> as
155      * a parameter for indexed property value retrieval.
156      */

157     public String JavaDoc getIndexedProperty() {
158         return this.indexedProperty;
159     }
160
161     /**
162      * Sets the indexed property name of the field.
163      */

164     public void setIndexedProperty(String JavaDoc indexedProperty) {
165         this.indexedProperty = indexedProperty;
166     }
167
168     /**
169      * Gets the indexed property name of the field. This
170      * is the method name that will return an array or a
171      * <code>Collection</code> used to retrieve the
172      * list and then loop through the list performing the specified
173      * validations.
174      */

175     public String JavaDoc getIndexedListProperty() {
176         return this.indexedListProperty;
177     }
178
179     /**
180      * Sets the indexed property name of the field.
181      */

182     public void setIndexedListProperty(String JavaDoc indexedListProperty) {
183         this.indexedListProperty = indexedListProperty;
184     }
185
186     /**
187      * Gets the validation rules for this field as a comma separated list.
188      */

189     public String JavaDoc getDepends() {
190         return this.depends;
191     }
192
193     /**
194      * Sets the validation rules for this field as a comma separated list.
195      * @param depends A comma separated list of validator names.
196      */

197     public void setDepends(String JavaDoc depends) {
198         this.depends = depends;
199
200         this.dependencyList.clear();
201
202         StringTokenizer JavaDoc st = new StringTokenizer JavaDoc(depends, ",");
203         while (st.hasMoreTokens()) {
204             String JavaDoc depend = st.nextToken().trim();
205
206             if (depend != null && depend.length() > 0) {
207                 this.dependencyList.add(depend);
208             }
209         }
210     }
211
212     /**
213      * Add a <code>Msg</code> to the <code>Field</code>.
214      */

215     public void addMsg(Msg msg) {
216         hMsgs.put(msg.getName(), msg);
217     }
218
219     /**
220      * Retrieve a message value.
221      */

222     public String JavaDoc getMsg(String JavaDoc key) {
223         Msg msg = getMessage(key);
224         return (msg == null) ? null : msg.getKey();
225     }
226
227     /**
228      * Retrieve a message object.
229      * @since Validator 1.1.4
230      */

231     public Msg getMessage(String JavaDoc key) {
232         return (Msg) hMsgs.get(key);
233     }
234
235     /**
236      * The <code>Field</code>'s messages are returned as an
237      * unmodifiable <code>Map</code>.
238      * @since Validator 1.1.4
239      */

240     public Map JavaDoc getMessages() {
241         return Collections.unmodifiableMap(hMsgs);
242     }
243
244     /**
245      * Add an <code>Arg</code> to the replacement argument list.
246      * @since Validator 1.1
247      */

248     public void addArg(Arg arg) {
249         // TODO this first if check can go away after arg0, etc. are removed from dtd
250
if (arg == null || arg.getKey() == null || arg.getKey().length() == 0) {
251             return;
252         }
253
254         determineArgPosition(arg);
255         ensureArgsCapacity(arg);
256
257         Map JavaDoc argMap = this.args[arg.getPosition()];
258         if (argMap == null) {
259             argMap = new HashMap JavaDoc();
260             this.args[arg.getPosition()] = argMap;
261         }
262
263         if (arg.getName() == null) {
264             argMap.put(DEFAULT_ARG, arg);
265         } else {
266             argMap.put(arg.getName(), arg);
267         }
268
269     }
270
271     /**
272      * Calculate the position of the Arg
273      */

274     private void determineArgPosition(Arg arg) {
275         
276         int position = arg.getPosition();
277
278         // position has been explicity set
279
if (position >= 0) {
280             return;
281         }
282
283         // first arg to be added
284
if (args == null || args.length == 0) {
285             arg.setPosition(0);
286             return;
287         }
288
289         // determine the position of the last argument with
290
// the same name or the last default argument
291
String JavaDoc key = arg.getName() == null ? DEFAULT_ARG : arg.getName();
292         int lastPosition = -1;
293         int lastDefault = -1;
294         for (int i = 0; i < args.length; i++) {
295             if (args[i] != null && args[i].containsKey(key)) {
296                 lastPosition = i;
297             }
298             if (args[i] != null && args[i].containsKey(DEFAULT_ARG)) {
299                 lastDefault = i;
300             }
301         }
302
303         if (lastPosition < 0) {
304             lastPosition = lastDefault;
305         }
306
307         // allocate the next position
308
arg.setPosition(++lastPosition);
309
310     }
311
312     /**
313      * Ensures that the args array can hold the given arg. Resizes the array as
314      * necessary.
315      * @param arg Determine if the args array is long enough to store this arg's
316      * position.
317      */

318     private void ensureArgsCapacity(Arg arg) {
319         if (arg.getPosition() >= this.args.length) {
320             Map JavaDoc[] newArgs = new Map JavaDoc[arg.getPosition() + 1];
321             System.arraycopy(this.args, 0, newArgs, 0, this.args.length);
322             this.args = newArgs;
323         }
324     }
325
326     /**
327      * Gets the default <code>Arg</code> object at the given position.
328      * @return The default Arg or null if not found.
329      * @since Validator 1.1
330      */

331     public Arg getArg(int position) {
332         return this.getArg(DEFAULT_ARG, position);
333     }
334
335     /**
336      * Gets the <code>Arg</code> object at the given position. If the key
337      * finds a <code>null</code> value then the default value will be
338      * retrieved.
339      * @param key The name the Arg is stored under. If not found, the default
340      * Arg for the given position (if any) will be retrieved.
341      * @param position The Arg number to find.
342      * @return The Arg with the given name and position or null if not found.
343      * @since Validator 1.1
344      */

345     public Arg getArg(String JavaDoc key, int position) {
346         if ((position >= this.args.length) || (this.args[position] == null)) {
347             return null;
348         }
349
350         Arg arg = (Arg) args[position].get(key);
351
352         // Didn't find default arg so exit, otherwise we would get into
353
// infinite recursion
354
if ((arg == null) && key.equals(DEFAULT_ARG)) {
355             return null;
356         }
357
358         return (arg == null) ? this.getArg(position) : arg;
359     }
360     
361     /**
362      * Retrieves the Args for the given validator name.
363      * @param key The validator's args to retrieve.
364      * @return An Arg[] sorted by the Args' positions (i.e. the Arg at index 0
365      * has a position of 0).
366      * @since Validator 1.1.1
367      */

368     public Arg[] getArgs(String JavaDoc key){
369         Arg[] args = new Arg[this.args.length];
370         
371         for (int i = 0; i < this.args.length; i++) {
372           args[i] = this.getArg(key, i);
373         }
374         
375         return args;
376     }
377
378     /**
379      * Add a <code>Var</code> to the <code>Field</code>.
380      */

381     public void addVar(Var v) {
382         this.hVars.put(v.getName(), v);
383     }
384
385     /**
386      * Add a <code>Var</code>, based on the values passed in, to the
387      * <code>Field</code>.
388      * @param name
389      * @param value
390      * @param jsType
391      */

392     public void addVar(String JavaDoc name, String JavaDoc value, String JavaDoc jsType) {
393         this.addVar(new Var(name, value, jsType));
394     }
395
396     /**
397      * Retrieve a variable.
398      * @param mainKey
399      */

400     public Var getVar(String JavaDoc mainKey) {
401         return (Var) hVars.get(mainKey);
402     }
403
404     /**
405      * Retrieve a variable's value.
406      * @param mainKey
407      */

408     public String JavaDoc getVarValue(String JavaDoc mainKey) {
409         String JavaDoc value = null;
410
411         Object JavaDoc o = hVars.get(mainKey);
412         if (o != null && o instanceof Var) {
413             Var v = (Var) o;
414             value = v.getValue();
415         }
416
417         return value;
418     }
419
420     /**
421      * The <code>Field</code>'s variables are returned as an
422      * unmodifiable <code>Map</code>.
423      */

424     public Map JavaDoc getVars() {
425         return Collections.unmodifiableMap(hVars);
426     }
427
428     /**
429      * Gets a unique key based on the property and indexedProperty fields.
430      */

431     public String JavaDoc getKey() {
432         if (this.key == null) {
433             this.generateKey();
434         }
435
436         return this.key;
437     }
438
439     /**
440      * Sets a unique key for the field. This can be used to change
441      * the key temporarily to have a unique key for an indexed field.
442      * @param key
443      */

444     public void setKey(String JavaDoc key) {
445         this.key = key;
446     }
447
448     /**
449      * If there is a value specified for the indexedProperty field then
450      * <code>true</code> will be returned. Otherwise it will be
451      * <code>false</code>.
452      */

453     public boolean isIndexed() {
454         return ((indexedListProperty != null && indexedListProperty.length() > 0));
455     }
456
457     /**
458      * Generate correct <code>key</code> value.
459      */

460     public void generateKey() {
461         if (this.isIndexed()) {
462             this.key = this.indexedListProperty + TOKEN_INDEXED + "." + this.property;
463         } else {
464             this.key = this.property;
465         }
466     }
467
468     /**
469      * Replace constants with values in fields and process the depends field
470      * to create the dependency <code>Map</code>.
471      */

472     void process(Map JavaDoc globalConstants, Map JavaDoc constants) {
473         this.hMsgs.setFast(false);
474         this.hVars.setFast(true);
475
476         this.generateKey();
477
478         // Process FormSet Constants
479
for (Iterator JavaDoc i = constants.keySet().iterator(); i.hasNext();) {
480             String JavaDoc key = (String JavaDoc) i.next();
481             String JavaDoc key2 = TOKEN_START + key + TOKEN_END;
482             String JavaDoc replaceValue = (String JavaDoc) constants.get(key);
483
484             property = ValidatorUtils.replace(property, key2, replaceValue);
485
486             processVars(key2, replaceValue);
487
488             this.processMessageComponents(key2, replaceValue);
489         }
490
491         // Process Global Constants
492
for (Iterator JavaDoc i = globalConstants.keySet().iterator(); i.hasNext();) {
493             String JavaDoc key = (String JavaDoc) i.next();
494             String JavaDoc key2 = TOKEN_START + key + TOKEN_END;
495             String JavaDoc replaceValue = (String JavaDoc) globalConstants.get(key);
496
497             property = ValidatorUtils.replace(property, key2, replaceValue);
498
499             processVars(key2, replaceValue);
500
501             this.processMessageComponents(key2, replaceValue);
502         }
503
504         // Process Var Constant Replacement
505
for (Iterator JavaDoc i = hVars.keySet().iterator(); i.hasNext();) {
506             String JavaDoc key = (String JavaDoc) i.next();
507             String JavaDoc key2 = TOKEN_START + TOKEN_VAR + key + TOKEN_END;
508             Var var = this.getVar(key);
509             String JavaDoc replaceValue = var.getValue();
510
511             this.processMessageComponents(key2, replaceValue);
512         }
513
514         hMsgs.setFast(true);
515     }
516
517     /**
518      * Replace the vars value with the key/value pairs passed in.
519      */

520     private void processVars(String JavaDoc key, String JavaDoc replaceValue) {
521         Iterator JavaDoc i = this.hVars.keySet().iterator();
522         while (i.hasNext()) {
523             String JavaDoc varKey = (String JavaDoc) i.next();
524             Var var = this.getVar(varKey);
525
526             var.setValue(ValidatorUtils.replace(var.getValue(), key, replaceValue));
527         }
528
529     }
530
531     /**
532      * Replace the args key value with the key/value pairs passed in.
533      */

534     private void processMessageComponents(String JavaDoc key, String JavaDoc replaceValue) {
535         String JavaDoc varKey = TOKEN_START + TOKEN_VAR;
536         // Process Messages
537
if (key != null && !key.startsWith(varKey)) {
538             for (Iterator JavaDoc i = hMsgs.values().iterator(); i.hasNext();) {
539                 Msg msg = (Msg) i.next();
540                 msg.setKey(ValidatorUtils.replace(msg.getKey(), key, replaceValue));
541             }
542         }
543
544         this.processArg(key, replaceValue);
545     }
546
547     /**
548      * Replace the arg <code>Collection</code> key value with the key/value
549      * pairs passed in.
550      */

551     private void processArg(String JavaDoc key, String JavaDoc replaceValue) {
552         for (int i = 0; i < this.args.length; i++) {
553
554             Map JavaDoc argMap = this.args[i];
555             if (argMap == null) {
556                 continue;
557             }
558
559             Iterator JavaDoc iter = argMap.values().iterator();
560             while (iter.hasNext()) {
561                 Arg arg = (Arg) iter.next();
562
563                 if (arg != null) {
564                     arg.setKey(
565                             ValidatorUtils.replace(arg.getKey(), key, replaceValue));
566                 }
567             }
568         }
569     }
570
571     /**
572      * Checks if the validator is listed as a dependency.
573      */

574     public boolean isDependency(String JavaDoc validatorName) {
575         return this.dependencyList.contains(validatorName);
576     }
577
578     /**
579      * Gets an unmodifiable <code>List</code> of the dependencies in the same
580      * order they were defined in parameter passed to the setDepends() method.
581      */

582     public List JavaDoc getDependencyList() {
583         return Collections.unmodifiableList(this.dependencyList);
584     }
585
586     /**
587      * Creates and returns a copy of this object.
588      */

589     public Object JavaDoc clone() {
590         Field field = null;
591         try {
592             field = (Field) super.clone();
593         } catch(CloneNotSupportedException JavaDoc e) {
594             throw new RuntimeException JavaDoc(e.toString());
595         }
596
597         field.args = new Map JavaDoc[this.args.length];
598         for (int i = 0; i < this.args.length; i++) {
599             if (this.args[i] == null) {
600                 continue;
601             }
602
603             Map JavaDoc argMap = new HashMap JavaDoc(this.args[i]);
604             Iterator JavaDoc iter = argMap.keySet().iterator();
605             while (iter.hasNext()) {
606                 String JavaDoc validatorName = (String JavaDoc) iter.next();
607                 Arg arg = (Arg) argMap.get(validatorName);
608                 argMap.put(validatorName, arg.clone());
609             }
610             field.args[i] = argMap;
611         }
612
613         field.hVars = ValidatorUtils.copyFastHashMap(hVars);
614         field.hMsgs = ValidatorUtils.copyFastHashMap(hMsgs);
615
616         return field;
617     }
618
619     /**
620      * Returns a string representation of the object.
621      */

622     public String JavaDoc toString() {
623         StringBuffer JavaDoc results = new StringBuffer JavaDoc();
624
625         results.append("\t\tkey = " + key + "\n");
626         results.append("\t\tproperty = " + property + "\n");
627         results.append("\t\tindexedProperty = " + indexedProperty + "\n");
628         results.append("\t\tindexedListProperty = " + indexedListProperty + "\n");
629         results.append("\t\tdepends = " + depends + "\n");
630         results.append("\t\tpage = " + page + "\n");
631         results.append("\t\tfieldOrder = " + fieldOrder + "\n");
632
633         if (hVars != null) {
634             results.append("\t\tVars:\n");
635             for (Iterator JavaDoc i = hVars.keySet().iterator(); i.hasNext();) {
636                 Object JavaDoc key = i.next();
637                 results.append("\t\t\t");
638                 results.append(key);
639                 results.append("=");
640                 results.append(hVars.get(key));
641                 results.append("\n");
642             }
643         }
644
645         return results.toString();
646     }
647     
648     /**
649      * Returns an indexed property from the object we're validating.
650      *
651      * @param bean The bean to extract the indexed values from.
652      * @throws ValidatorException If there's an error looking up the property
653      * or, the property found is not indexed.
654      */

655     Object JavaDoc[] getIndexedProperty(Object JavaDoc bean) throws ValidatorException {
656         Object JavaDoc indexedProperty = null;
657
658         try {
659             indexedProperty =
660                 PropertyUtils.getProperty(bean, this.getIndexedListProperty());
661
662         } catch(IllegalAccessException JavaDoc e) {
663             throw new ValidatorException(e.getMessage());
664         } catch(InvocationTargetException JavaDoc e) {
665             throw new ValidatorException(e.getMessage());
666         } catch(NoSuchMethodException JavaDoc e) {
667             throw new ValidatorException(e.getMessage());
668         }
669
670         if (indexedProperty instanceof Collection JavaDoc) {
671             return ((Collection JavaDoc) indexedProperty).toArray();
672
673         } else if (indexedProperty.getClass().isArray()) {
674             return (Object JavaDoc[]) indexedProperty;
675
676         } else {
677             throw new ValidatorException(this.getKey() + " is not indexed");
678         }
679
680     }
681     
682     /**
683      * Executes the given ValidatorAction and all ValidatorActions that it
684      * depends on.
685      * @return true if the validation succeeded.
686      */

687     private boolean validateForRule(
688         ValidatorAction va,
689         ValidatorResults results,
690         Map JavaDoc actions,
691         Map JavaDoc params,
692         int pos)
693         throws ValidatorException {
694
695         ValidatorResult result = results.getValidatorResult(this.getKey());
696         if (result != null && result.containsAction(va.getName())) {
697             return result.isValid(va.getName());
698         }
699
700         if (!this.runDependentValidators(va, results, actions, params, pos)) {
701             return false;
702         }
703
704         return va.executeValidationMethod(this, params, results, pos);
705     }
706
707     /**
708      * Calls all of the validators that this validator depends on.
709      * TODO ValidatorAction should know how to run its own dependencies.
710      * @param va Run dependent validators for this action.
711      * @param results
712      * @param actions
713      * @param pos
714      * @return true if all of the dependent validations passed.
715      * @throws ValidatorException
716      */

717     private boolean runDependentValidators(
718         ValidatorAction va,
719         ValidatorResults results,
720         Map JavaDoc actions,
721         Map JavaDoc params,
722         int pos)
723         throws ValidatorException {
724
725         List JavaDoc dependentValidators = va.getDependencyList();
726
727         if (dependentValidators.isEmpty()) {
728             return true;
729         }
730
731         Iterator JavaDoc iter = dependentValidators.iterator();
732         while (iter.hasNext()) {
733             String JavaDoc depend = (String JavaDoc) iter.next();
734
735             ValidatorAction action = (ValidatorAction) actions.get(depend);
736             if (action == null) {
737                 this.handleMissingAction(depend);
738             }
739
740             if (!this.validateForRule(action, results, actions, params, pos)) {
741                 return false;
742             }
743         }
744
745         return true;
746     }
747
748     /**
749      * Run the configured validations on this field. Run all validations
750      * in the depends clause over each item in turn, returning when the first
751      * one fails.
752      * @param params A Map of parameter class names to parameter values to pass
753      * into validation methods.
754      * @param actions A Map of validator names to ValidatorAction objects.
755      * @return A ValidatorResults object containing validation messages for
756      * this field.
757      */

758     ValidatorResults validate(Map JavaDoc params, Map JavaDoc actions)
759         throws ValidatorException {
760         
761         if (this.getDepends() == null) {
762             return new ValidatorResults();
763         }
764
765         ValidatorResults allResults = new ValidatorResults();
766
767         Object JavaDoc bean = params.get(Validator.BEAN_PARAM);
768         int numberOfFieldsToValidate =
769             this.isIndexed() ? this.getIndexedProperty(bean).length : 1;
770
771         for (int fieldNumber = 0; fieldNumber < numberOfFieldsToValidate; fieldNumber++) {
772             
773             Iterator JavaDoc dependencies = this.dependencyList.iterator();
774             while (dependencies.hasNext()) {
775                 String JavaDoc depend = (String JavaDoc) dependencies.next();
776
777                 ValidatorAction action = (ValidatorAction) actions.get(depend);
778                 if (action == null) {
779                     this.handleMissingAction(depend);
780                 }
781
782                 ValidatorResults results = new ValidatorResults();
783                 boolean good =
784                     validateForRule(action, results, actions, params, fieldNumber);
785
786                 allResults.merge(results);
787
788                 if (!good) {
789                     return allResults;
790                 }
791             }
792         }
793         
794         return allResults;
795     }
796     
797     /**
798      * Called when a validator name is used in a depends clause but there is
799      * no know ValidatorAction configured for that name.
800      * @param name The name of the validator in the depends list.
801      * @throws ValidatorException
802      */

803     private void handleMissingAction(String JavaDoc name) throws ValidatorException {
804         throw new ValidatorException("No ValidatorAction named " + name
805                 + " found for field " + this.getProperty());
806     }
807
808     /**
809      * Returns a Map of String Msg names to Msg objects.
810      * @since Validator 1.2.0
811      */

812     protected Map JavaDoc getMsgMap() {
813         return hMsgs;
814     }
815
816     /**
817      * Returns a Map of String Var names to Var objects.
818      * @since Validator 1.2.0
819      */

820     protected Map JavaDoc getVarMap() {
821         return hVars;
822     }
823
824 }
825
826
Popular Tags