01: /*
02: * Copyright 2004 The Apache Software Foundation.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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.myfaces.context.servlet;
17:
18: import java.util.Enumeration;
19:
20: import javax.servlet.ServletRequest;
21:
22: import org.apache.myfaces.util.AbstractAttributeMap;
23:
24: /**
25: * ServletRequest parameters as Map.
26: *
27: * @author Anton Koinov (latest modification by $Author: mbr $)
28: * @version $Revision: 512417 $ $Date: 2007-02-27 22:22:36 +0100 (Di, 27 Feb 2007) $
29: */
30: public class RequestParameterMap extends AbstractAttributeMap<String> {
31: private final ServletRequest _servletRequest;
32:
33: RequestParameterMap(ServletRequest servletRequest) {
34: _servletRequest = servletRequest;
35: }
36:
37: @Override
38: protected String getAttribute(String key) {
39: return _servletRequest.getParameter(key);
40: }
41:
42: @Override
43: protected void setAttribute(String key, String value) {
44: throw new UnsupportedOperationException(
45: "Cannot set ServletRequest Parameter");
46: }
47:
48: @Override
49: protected void removeAttribute(String key) {
50: throw new UnsupportedOperationException(
51: "Cannot remove ServletRequest Parameter");
52: }
53:
54: @Override
55: @SuppressWarnings("unchecked")
56: protected Enumeration<String> getAttributeNames() {
57: return _servletRequest.getParameterNames();
58: }
59: }
|