KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > faces > context > RequestMap


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
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.apache.cocoon.faces.context;
17
18 import org.apache.cocoon.environment.Request;
19
20 import java.util.Enumeration JavaDoc;
21 import java.util.HashSet JavaDoc;
22 import java.util.Set JavaDoc;
23
24 /**
25  * Request attributes map
26  *
27  * @author <a HREF="mailto:vgritsenko@apache.org">Vadim Gritsenko</a>
28  * @version CVS $Id: RequestMap.java 46253 2004-09-17 14:36:29Z vgritsenko $
29  */

30 class RequestMap extends BaseMap {
31
32     private Request request;
33
34
35     RequestMap(Request request) {
36         this.request = request;
37     }
38
39     public Object JavaDoc get(Object JavaDoc key) {
40         return request.getAttribute(key.toString());
41     }
42
43     public Object JavaDoc put(Object JavaDoc key, Object JavaDoc value) {
44         String JavaDoc sKey = key.toString();
45         Object JavaDoc old = request.getAttribute(sKey);
46         request.setAttribute(sKey, value);
47         return old;
48     }
49
50     public Object JavaDoc remove(Object JavaDoc key) {
51         String JavaDoc sKey = key.toString();
52         Object JavaDoc old = request.getAttribute(sKey);
53         request.removeAttribute(sKey);
54         return old;
55     }
56
57     public Set JavaDoc entrySet() {
58         Set JavaDoc entries = new HashSet JavaDoc();
59         for (Enumeration JavaDoc e = request.getAttributeNames(); e.hasMoreElements();) {
60             String JavaDoc name = (String JavaDoc) e.nextElement();
61             entries.add(new BaseMap.Entry(name, request.getAttribute(name)));
62         }
63
64         return entries;
65     }
66
67     public boolean equals(Object JavaDoc obj) {
68         if (obj == null || !(obj instanceof RequestMap)) {
69             return false;
70         }
71
72         return super.equals(obj);
73     }
74 }
75
Popular Tags