01: /*
02: * Copyright 2006 Dan Shellman
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.iscreen;
17:
18: import java.util.Locale;
19:
20: /**
21: * During validation, a Validator is given a reference to the context in which
22: * it is validating. The primary purpose of this context is to provide a means
23: * for the Validator to report validation failures. In the future, additional
24: * APIs will be added to support additional contextual information for use
25: * by the Validator.
26: *
27: * @author Shellman, Dan
28: */
29: public interface ValidatorContext {
30: /**
31: * Called to report a validation failure. The Object provided is the failure
32: * message (usually configured as a setter on the individual Validator).
33: *
34: * @param messageObject The message failure object representing the failure.
35: */
36: void reportFailure(FailureMessage messageObject);
37:
38: /**
39: * Called to report a validation failure. The Object provided is the failure
40: * message (usually configured as a setter on the individual Validator). The
41: * additional failure object is used to help generate the actual failure
42: * message (it becomes accessible to the message via the OGNL root).
43: *
44: * @param messageObject The message failure object representing the failure.
45: * @param failureObject A Validator-specific failure object to be made
46: * accessible to the message via the OGNL root.
47: */
48: void reportFailure(FailureMessage messageObject,
49: Object failureObject);
50:
51: /**
52: * Called to report a validation warning. The Object provided is the failure
53: * message (usually configured as a setter on the individual Validator). A
54: * warning is handled as a separate exception that allows the user of this
55: * API to differentiate between validation failures and warnings.
56: *
57: * @param messageObject The message failure object representing the warning.
58: */
59: void reportWarning(FailureMessage messageObject);
60:
61: /**
62: * Called to report a validation warning. The Object provided is the failure
63: * message (usually configured as a setter on the individual Validator). The
64: * additional failure object is used to help generate the actual failure
65: * message (it becomes accessible to the message via the OGNL root). A
66: * warning is handled as a separate exception that allows the user of this
67: * API to differentiate between validation failures and warnings.
68: *
69: * @param messageObject The message failure object representing the warning.
70: * @param failureObject A Validator-specific failure object to be made
71: * accessible to the message via the OGNL root.
72: */
73: void reportWarning(FailureMessage messageObject,
74: Object failureObject);
75:
76: /**
77: * Gets the current locale being used for this validation.
78: *
79: * @return Returns the current locale being used.
80: */
81: Locale getLocale();
82: }
|