KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > validation > MapBindingResult


1 /*
2  * Copyright 2002-2006 the original author or authors.
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
17 package org.springframework.validation;
18
19 import java.io.Serializable JavaDoc;
20 import java.util.Map JavaDoc;
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 Serializable JavaDoc {
37
38     private final Map JavaDoc target;
39
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 JavaDoc target, String JavaDoc objectName) {
47         super(objectName);
48         Assert.notNull(target, "Target Map must not be null");
49         this.target = target;
50     }
51
52
53     public final Map JavaDoc getTargetMap() {
54         return this.target;
55     }
56
57     public final Object JavaDoc getTarget() {
58         return this.target;
59     }
60
61     protected Object JavaDoc getActualFieldValue(String JavaDoc field) {
62         return this.target.get(field);
63     }
64
65 }
66
Popular Tags