View Javadoc

1   /*
2    * Copyright 2000-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 com.ibatis.struts.httpmap;
17  
18  import com.ibatis.struts.httpmap.BaseHttpMap;
19  
20  import javax.servlet.http.HttpServletRequest;
21  import java.util.Enumeration;
22  
23  /***
24   * Map to wrap request scope attributes.
25   * <p/>
26   * Date: Mar 11, 2004 10:35:34 PM
27   *
28   * @author Clinton Begin
29   */
30  public class RequestMap extends BaseHttpMap {
31  
32    private HttpServletRequest request;
33  
34    public RequestMap(HttpServletRequest request) {
35      this.request = request;
36    }
37  
38    protected Enumeration getNames() {
39      return request.getAttributeNames();
40    }
41  
42    protected Object getValue(Object key) {
43      return request.getAttribute(String.valueOf(key));
44    }
45  
46    protected void putValue(Object key, Object value) {
47      request.setAttribute(String.valueOf(key), value);
48    }
49  
50    protected void removeValue(Object key) {
51      request.removeAttribute(String.valueOf(key));
52    }
53  
54  }