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 for a central instance that manages validation
21 * messages.
22 * </p>
23 * <p>
24 * This interface is used by concrete <code>{@link Validator}</code>
25 * implementations to obtain meaningful error messages when they decide that
26 * user input is not valid. An object implementing this interface can be queried
27 * from the <code>{@link TransformerContext}</code>. It can then be used for
28 * requesting <code>{@link ValidationMessage}</code> objects for specified
29 * keys.
30 * </p>
31 * <p>
32 * Because all validation error messages are obtained through this interface, it
33 * provides a way for hooking into the mechanism of creating error messages.
34 * While the framework ships a fully functional default implementation, an
35 * application with completely different requirements can choose to use a custom
36 * implementation.
37 * </p>
38 *
39 * @author Oliver Heger
40 * @version $Id: ValidationMessageHandler.java 205 2012-01-29 18:29:57Z oheger $
41 */
42 public interface ValidationMessageHandler
43 {
44 /**
45 * Returns a <code>ValidationMessage</code> object for the specified key.
46 * The message will be initialized with the given parameters. From this
47 * object the final error message can be obtained.
48 *
49 * @param context the transformer context
50 * @param key the key for the validation message
51 * @param params an array with additional parameters
52 * @return the corresponding <code>ValidationMessage</code> object
53 */
54 ValidationMessage getValidationMessage(TransformerContext context,
55 String key, Object... params);
56 }