01: package net.xoetrope.xui.validation;
02:
03: import java.lang.reflect.Method;
04:
05: import java.awt.Component;
06: import java.awt.Container;
07:
08: /**
09: * <p>An interface describing a validator. The work of teh validator will be
10: * done in the validate method. If an error is called then an exception will be
11: * thrown. Typically the exception will be caught in a panel class such as
12: * XPage. The handleException method of a XValidationExceptionHandler
13: * implementation will then be invoked.</p>
14: * <p>Copyright: Copyright (c) Xoetrope Ltd., 1998-2003<br>
15: * License: see license.txt</p>
16: * $Revision: 1.9 $
17: */
18: public interface XValidator {
19: public void validate(Component c, boolean forceMandatory)
20: throws Exception;
21:
22: /**
23: * Get the event mask. The mask helps filter the events for which the
24: * validator is invoked
25: * @return the mask
26: */
27: public int getMask();
28:
29: /**
30: * Set the Method of the XPage to be invoked when we are doing a funcion
31: * validation
32: * @param m The method to be invoked
33: * @param page The XPage which contains the Method.
34: */
35: public void setValidationMethod(Method m, Container page);
36:
37: /**
38: * Get the name of the validation
39: * @return The name
40: */
41: public String getName();
42:
43: /**
44: * Get the validation message which is formatted after the tokens have been
45: * replaced
46: * @return The formatted message.
47: */
48: public String getMessage();
49:
50: /**
51: * Get the value as a string object
52: * @return the value as string
53: */
54: public String getValueAsString();
55:
56: /**
57: * Get the error level of the validations
58: * <OL>
59: * <LI>LEVEL_IGNORE = 0</LI>
60: * <LI>LEVEL_WARNING = 1</LI>
61: * <LI>LEVEL_ERROR = 2</LI>
62: * <LI>IGNORE_BLANKS = 1024</LI>
63: * <LI>MANDATORY = 2048</LI>
64: * <LI>WEAK_CHECK = 4096</LI>
65: * <LI>STRICT_CHECK = 8192</LI>
66: * </OL>
67: * @return the error level
68: */
69: public int getLevel();
70:
71: public static final int LEVEL_IGNORE = 0;
72: public static final int LEVEL_WARNING = 1;
73: public static final int LEVEL_ERROR = 2;
74: public static final int IGNORE_BLANKS = 1024;
75: public static final int MANDATORY = 2048;
76: public static final int WEAK_CHECK = 4096;
77: public static final int STRICT_CHECK = 8192;
78: }
|