KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > webflow > execution > support > ApplicationView


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 package org.springframework.webflow.execution.support;
17
18 import java.util.Collections JavaDoc;
19 import java.util.Map JavaDoc;
20
21 import org.springframework.util.ObjectUtils;
22 import org.springframework.webflow.execution.ViewSelection;
23
24 /**
25  * Concrete response type that requests the rendering of a local, internal
26  * application view resource such as a JSP, Velocity, or FreeMarker template.
27  * <p>
28  * This is typically the most common type of view selection.
29  *
30  * @author Keith Donald
31  * @author Erwin Vervaet
32  */

33 public final class ApplicationView extends ViewSelection {
34
35     /**
36      * The name of the view (or page or other response) to render. This name may
37      * identify a <i>logical</i> view resource or may be a <i>physical</i>
38      * path to an internal view template.
39      */

40     private final String JavaDoc viewName;
41
42     /**
43      * A map of the application data to make available to the view for
44      * rendering.
45      */

46     private final Map JavaDoc model;
47
48     /**
49      * Creates a new application view.
50      * @param viewName the name (or resource identifier) of the view that should
51      * be rendered
52      * @param model the map of application model data to make available to the
53      * view during rendering; entries consist of model names (Strings) to model
54      * objects (Objects), model entries may not be null, but the model Map may
55      * be null if there is no model data
56      */

57     public ApplicationView(String JavaDoc viewName, Map JavaDoc model) {
58         if (model == null) {
59             model = Collections.EMPTY_MAP;
60         }
61         this.viewName = viewName;
62         this.model = model;
63     }
64
65     /**
66      * Returns the name of the view to render.
67      */

68     public String JavaDoc getViewName() {
69         return viewName;
70     }
71
72     /**
73      * Return the view's application model that should be made available during
74      * the rendering process. Never returns null. The returned map is unmodifiable.
75      */

76     public Map JavaDoc getModel() {
77         return Collections.unmodifiableMap(model);
78     }
79
80     public boolean equals(Object JavaDoc o) {
81         if (!(o instanceof ApplicationView)) {
82             return false;
83         }
84         ApplicationView other = (ApplicationView)o;
85         return ObjectUtils.nullSafeEquals(viewName, other.viewName) && model.equals(other.model);
86     }
87
88     public int hashCode() {
89         return (viewName != null ? viewName.hashCode() : 0) + model.hashCode();
90     }
91
92     public String JavaDoc toString() {
93         return "'" + viewName + "' [" + model.keySet() + "]";
94     }
95 }
Popular Tags