1
16package org.tp23.antinstaller.input;
17
18import java.io.File;
19
20import org.tp23.antinstaller.InstallerContext;
21import org.tp23.antinstaller.ValidationException;
22
23
24
33public class FileInput
34 extends OSSpecific{
35
36 private boolean abort = false;
37 private String checkExists;
38
39 public FileInput() {
40 }
41
42
45 public boolean validate(InstallerContext ctx) throws ValidationException{
46 if (getInputResult() == null) { return false;
48 }
49 if(InputField.isTrue(checkExists)){
50 File file = new File(getInputResult());
51 if(!file.exists()){
52 return false;
53 }
54 }
55 return true;
56 }
57
58 public boolean isAbort() {
59 return abort;
60 }
61
62 public void setAbort(boolean abort) {
63 this.abort = abort;
64 }
65
66 public String getCheckExists() {
67 return checkExists;
68 }
69 public void setCheckExists(String checkExists) {
70 this.checkExists = checkExists;
71 }
72 public void setValue(String dir){
73 setInputResult(dir);
74 }
75
76
81 public boolean validateObject() {
82 if(getDisplayText()==null){
83 System.out.println("File:displayText must be set");
84 return false;
85 }
86 if(getProperty()==null){
87 System.out.println("File:property must be set");
88 return false;
89 }
90 if(getDefaultValue()==null){
91 System.out.println("File:defaultValue must be set");
92 return false;
93 }
94 if(!InputField.optionalBoolean(getCheckExists())){
95 System.out.println("File:checkExists must be true or false or null");
96 return false;
97 }
98 return true;
99 }
00}
01