01: package com.izforge.izpack.panels;
02:
03: import java.util.Map;
04:
05: /**
06: *
07: * @author Jeff Gordon
08: */
09: public class ValidatorContainer {
10: private Validator validator = null;
11: private String message;
12: private boolean hasParams = false;
13: private Map<String, String> validatorParams = null;
14:
15: public ValidatorContainer(String validator, String message,
16: Map<String, String> validatorParams) {
17: try {
18: this .validator = (Validator) Class.forName(validator)
19: .newInstance();
20: this .message = message;
21: this .validatorParams = validatorParams;
22: if (validatorParams != null) {
23: if (validatorParams.size() > 0) {
24: hasParams = true;
25: }
26: }
27: } catch (Throwable e) {
28: System.out
29: .println("ValidatorContainer Constructor Failed: "
30: + e);
31: this .validator = null;
32: this .message = null;
33: hasParams = false;
34: validatorParams = null;
35: }
36: }
37:
38: /**
39: * @return true if this instance has any parameters to pass to the Validator instance.
40: */
41: public boolean hasParams() {
42: return hasParams;
43: }
44:
45: /**
46: * Returns the validator parameters, if any. The caller should check for the existence of
47: * validator parameters via the <code>hasParams()</code> method prior to invoking this method.
48: *
49: * @return a java.util.Map containing the validator parameters.
50: */
51: public Map<String, String> getValidatorParams() {
52: return validatorParams;
53: }
54:
55: public Validator getValidator() {
56: return validator;
57: }
58:
59: public String getMessage() {
60: return message;
61: }
62:
63: }
|