01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.cocoon.faces.context;
18:
19: import org.apache.cocoon.environment.Request;
20:
21: import java.util.Enumeration;
22: import java.util.HashSet;
23: import java.util.Set;
24:
25: /**
26: * Request attributes map
27: *
28: * @author <a href="mailto:vgritsenko@apache.org">Vadim Gritsenko</a>
29: * @version CVS $Id: RequestMap.java 433543 2006-08-22 06:22:54Z crossley $
30: */
31: class RequestMap extends BaseMap {
32:
33: private Request request;
34:
35: RequestMap(Request request) {
36: this .request = request;
37: }
38:
39: public Object get(Object key) {
40: return request.getAttribute(key.toString());
41: }
42:
43: public Object put(Object key, Object value) {
44: String sKey = key.toString();
45: Object old = request.getAttribute(sKey);
46: request.setAttribute(sKey, value);
47: return old;
48: }
49:
50: public Object remove(Object key) {
51: String sKey = key.toString();
52: Object old = request.getAttribute(sKey);
53: request.removeAttribute(sKey);
54: return old;
55: }
56:
57: public Set entrySet() {
58: Set entries = new HashSet();
59: for (Enumeration e = request.getAttributeNames(); e
60: .hasMoreElements();) {
61: String name = (String) e.nextElement();
62: entries.add(new BaseMap.Entry(name, request
63: .getAttribute(name)));
64: }
65:
66: return entries;
67: }
68:
69: public boolean equals(Object obj) {
70: if (obj == null || !(obj instanceof RequestMap)) {
71: return false;
72: }
73:
74: return super.equals(obj);
75: }
76: }
|