01: /*
02: * Copyright 2002-2005 the original author or authors.
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:
17: package org.springframework.validation;
18:
19: /**
20: * Strategy interface for building message codes from validation error codes.
21: * Used by DataBinder to build the codes list for ObjectErrors and FieldErrors.
22: *
23: * <p>The resulting message codes correspond to the codes of a
24: * MessageSourceResolvable (as implemented by ObjectError and FieldError).
25: *
26: * @author Juergen Hoeller
27: * @since 1.0.1
28: * @see DataBinder#setMessageCodesResolver
29: * @see ObjectError
30: * @see FieldError
31: * @see org.springframework.context.MessageSourceResolvable#getCodes()
32: */
33: public interface MessageCodesResolver {
34:
35: /**
36: * Build message codes for the given error code and object name.
37: * Used for building the codes list of an ObjectError.
38: * @param errorCode the error code used for rejecting the object
39: * @param objectName the name of the object
40: * @return the message codes to use
41: */
42: String[] resolveMessageCodes(String errorCode, String objectName);
43:
44: /**
45: * Build message codes for the given error code and field specification.
46: * Used for building the codes list of an FieldError.
47: * @param errorCode the error code used for rejecting the value
48: * @param objectName the name of the object
49: * @param field the field name
50: * @param fieldType the field type (may be <code>null</code> if not determinable)
51: * @return the message codes to use
52: */
53: String[] resolveMessageCodes(String errorCode, String objectName,
54: String field, Class fieldType);
55:
56: }
|