View Javadoc

1   /*
2    * Copyright 2004-2010 the Seasar Foundation and the Others.
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,
13   * either express or implied. See the License for the specific language
14   * governing permissions and limitations under the License.
15   */
16  
17  package org.seasar.cubby.action;
18  
19  import java.util.Collection;
20  import java.util.Map;
21  import java.util.Set;
22  
23  import javax.servlet.ServletRequest;
24  
25  /**
26   * 揮発性メッセージへアクセスするプロキシです。
27   * 
28   * @since 2.0.5
29   * @author baba
30   */
31  public class FlashMapProxy implements FlashMap {
32  
33  	/** アクションコンテキストのヘルパー */
34  	private final ActionContextHelper actionContextHelper;
35  
36  	/**
37  	 * 指定された要求の属性に設定された揮発性メッセージへアクセスするプロキシを生成します。
38  	 * 
39  	 * @param request
40  	 *            要求
41  	 */
42  	public FlashMapProxy(final ServletRequest request) {
43  		this.actionContextHelper = new ActionContextHelper(request);
44  	}
45  
46  	/**
47  	 * {@inheritDoc}
48  	 */
49  	public int size() {
50  		return subject().size();
51  	}
52  
53  	/**
54  	 * {@inheritDoc}
55  	 */
56  	public boolean isEmpty() {
57  		return subject().isEmpty();
58  	}
59  
60  	/**
61  	 * {@inheritDoc}
62  	 */
63  	public boolean containsKey(final Object key) {
64  		return subject().containsKey(key);
65  	}
66  
67  	/**
68  	 * {@inheritDoc}
69  	 */
70  	public boolean containsValue(final Object value) {
71  		return subject().containsValue(value);
72  	}
73  
74  	/**
75  	 * {@inheritDoc}
76  	 */
77  	public Object get(final Object key) {
78  		return subject().get(key);
79  	}
80  
81  	/**
82  	 * {@inheritDoc}
83  	 */
84  	public Object put(final String key, final Object value) {
85  		return subject().put(key, value);
86  	}
87  
88  	/**
89  	 * {@inheritDoc}
90  	 */
91  	public Object remove(final Object key) {
92  		return subject().remove(key);
93  	}
94  
95  	/**
96  	 * {@inheritDoc}
97  	 */
98  	public void putAll(final Map<? extends String, ? extends Object> t) {
99  		subject().putAll(t);
100 	}
101 
102 	/**
103 	 * {@inheritDoc}
104 	 */
105 	public void clear() {
106 		subject().clear();
107 	}
108 
109 	/**
110 	 * {@inheritDoc}
111 	 */
112 	public Set<String> keySet() {
113 		return subject().keySet();
114 	}
115 
116 	/**
117 	 * {@inheritDoc}
118 	 */
119 	public Collection<Object> values() {
120 		return subject().values();
121 	}
122 
123 	/**
124 	 * {@inheritDoc}
125 	 */
126 	public Set<java.util.Map.Entry<String, Object>> entrySet() {
127 		return subject().entrySet();
128 	}
129 
130 	/**
131 	 * 要求の属性から被代理オブジェクトを取得します。
132 	 * 
133 	 * @return 被代理オブジェクト
134 	 */
135 	protected Map<String, Object> subject() {
136 		return actionContextHelper.getActionContext().getFlashMap();
137 	}
138 }