01: package org.tp23.antinstaller.input;
02:
03: import java.util.Locale;
04:
05: import org.tp23.antinstaller.InstallerContext;
06:
07: /**
08: * A no args constructor should be provided
09: * @author Paul Hinds
10: * @version $Id: Validator.java,v 1.1.1.1 2005/10/18 18:20:54 teknopaul Exp $
11: */
12: public interface Validator {
13:
14: /**
15: * Validate the user entry. The InstallerContext is provided to allow
16: * conditional failure based on user input. for example the implementation
17: * of this class could call the following code after failing to open a socket
18: * <pre>
19: * boolean usrOverride = ctx.getMessageRenderer().prompt("Prot not available are you sure?");
20: * if(userOverride)return true;
21: * else{
22: * throw new SocketException();
23: * }
24: * </pre>
25: * @param text may be null it is up to the validator to decide if null or ""
26: * is acceptable
27: * @throws Exception
28: */
29: public void validate(String text, InstallerContext ctx)
30: throws Exception;
31:
32: /**
33: * This method should return a string for every exception that might be
34: * thrown by the validate method. The top level Throwable should be
35: * handled at least.
36: * @param ex
37: * @param l Locale (ignored, but one day we should be internationalized)
38: * @return
39: */
40: public String getErrorMessage(Throwable ex, Locale l);
41: }
|