1 /*
2 * Copyright 2006-2016 The JGUIraffe Team.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License")
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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 net.sf.jguiraffe.transform;
17
18 /**
19 * <p>
20 * Definition of an interface describing a validation message.
21 * </p>
22 * <p>
23 * If a {@link Validator} cannot successfully validate an input field, it
24 * creates a {@link ValidationResult} object that not only indicates the
25 * validation error, but also contains corresponding error messages to be
26 * displayed to the user. These error messages are represented by this
27 * interface.
28 * </p>
29 * <p>
30 * The idea behind this interface is that there can be multiple ways of
31 * obtaining the error message for the user. For instance it can be directly
32 * specified as text or loaded from the application's resources. By making use
33 * of an interface the actual source of the message is transparent for the
34 * client.
35 * </p>
36 * <p>
37 * A validation message consists of a text that can be directly displayed to the
38 * user. This text should be informative, so that the user knows what is wrong
39 * and how it can be fixed. The default validators shipped with this framework
40 * are able to provide meaningful error messages. In addition to the text, a
41 * validation message also contains a unique key. The existing validator
42 * implementations document the error keys they can produce. Further, a level
43 * for the severity of the message can be specified. The level determines
44 * whether the message is considered an error or not.
45 * </p>
46 *
47 * @author Oliver Heger
48 * @version $Id: ValidationMessage.java 205 2012-01-29 18:29:57Z oheger $
49 */
50 public interface ValidationMessage
51 {
52 /**
53 * Returns the key of this validation message. Validation messages have a
54 * unique key. (This key can for instance be used for changing the text of a
55 * specific validation message.)
56 *
57 * @return the key of this validation message
58 */
59 String getKey();
60
61 /**
62 * Returns the {@code ValidationMessageLevel} associated with this message.
63 * This level determines the severity of this message.
64 *
65 * @return the {@code ValidationMessageLevel}
66 */
67 ValidationMessageLevel getLevel();
68
69 /**
70 * Returns the actual message. This is a text that can be directly displayed
71 * to the user.
72 *
73 * @return the error message in plain text
74 */
75 String getMessage();
76 }