01: /*
02: * Copyright 2002-2006 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: import java.io.Serializable;
20: import java.util.Map;
21:
22: import org.springframework.util.Assert;
23:
24: /**
25: * Map-based implementation of the BindingResult interface,
26: * supporting registration and evaluation of binding errors on
27: * Map attributes.
28: *
29: * <p>Can be used as errors holder for custom binding onto a
30: * Map, for example when invoking a Validator for a Map object.
31: *
32: * @author Juergen Hoeller
33: * @since 2.0
34: * @see java.util.Map
35: */
36: public class MapBindingResult extends AbstractBindingResult implements
37: Serializable {
38:
39: private final Map target;
40:
41: /**
42: * Create a new MapBindingResult instance.
43: * @param target the target Map to bind onto
44: * @param objectName the name of the target object
45: */
46: public MapBindingResult(Map target, String objectName) {
47: super (objectName);
48: Assert.notNull(target, "Target Map must not be null");
49: this .target = target;
50: }
51:
52: public final Map getTargetMap() {
53: return this .target;
54: }
55:
56: public final Object getTarget() {
57: return this .target;
58: }
59:
60: protected Object getActualFieldValue(String field) {
61: return this.target.get(field);
62: }
63:
64: }
|