1
16package org.tp23.antinstaller.input;
17
18
19
20import org.tp23.antinstaller.InstallerContext;
21import org.tp23.antinstaller.ValidationException;
22
23
24
33public class ExtValidatedTextInput
34 extends ValidatedTextInput{
35
36 private String validationClass;
37 private Validator validator;
38 private Throwable throwable ;
39
40 public ExtValidatedTextInput() {
41 }
42
43 public void setValue(String dir){
44 setInputResult(dir);
45 }
46 public String getValidationClass() {
47 return validationClass;
48 }
49 public void setValidationClass(String validationClass) {
50 this.validationClass = validationClass;
51 try {
52 validator = (Validator)Class.forName(validationClass).newInstance();
53 }
54 catch (Exception ex) {
55 throw new InputException("Invalid Class in ExtValidated text input");
56 }
57 }
58
59
62 public boolean validate(InstallerContext ctx) throws ValidationException{
63 String result = getInputResult();
64 try{
65 validator.validate(result,ctx);
66 throwable = null;
67 return true;
68 }
69 catch(Throwable t){
70 throwable = t;
71 return false;
72 }
73
74 }
75
78 public Validator getValidator() {
79 return validator;
80 }
81
82
87 public boolean validateObject() {
88 if(getDisplayText() == null){
89 System.out.println("ExtValidated:displayText must be set");
90 return false;
91 }
92 if(getProperty() == null){
93 System.out.println("ExtValidated:property must be set");
94 return false;
95 }
96 if(getValidationClass() == null){
97 System.out.println("ExtValidated:validationClass must be set");
98 return false;
99 }
00 return true;
01 }
02
05 public Throwable getThrowable() {
06 return throwable;
07 }
08}
09