001: /*
002: * Copyright 1999,2004 The Apache Software Foundation.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016:
017: package org.apache.catalina.connector;
018:
019: import java.io.BufferedReader;
020: import java.io.IOException;
021: import java.util.Enumeration;
022: import java.util.Locale;
023: import java.util.Map;
024:
025: import javax.servlet.RequestDispatcher;
026: import javax.servlet.ServletInputStream;
027: import javax.servlet.ServletRequest;
028:
029: import org.apache.catalina.Request;
030:
031: /**
032: * Facade class that wraps a Catalina-internal <b>Request</b>
033: * object. All methods are delegated to the wrapped request.
034: *
035: * @author Craig R. McClanahan
036: * @author Remy Maucherat
037: * @author Jean-Francois Arcand
038: * @version $Revision: 1.4 $ $Date: 2004/02/27 14:58:41 $
039: */
040:
041: public class RequestFacade implements ServletRequest {
042:
043: // ----------------------------------------------------------- Constructors
044:
045: /**
046: * Construct a wrapper for the specified request.
047: *
048: * @param request The request to be wrapped
049: */
050: public RequestFacade(Request request) {
051:
052: super ();
053: this .request = (ServletRequest) request;
054:
055: }
056:
057: // ----------------------------------------------------- Instance Variables
058:
059: /**
060: * The wrapped request.
061: */
062: protected ServletRequest request = null;
063:
064: // --------------------------------------------------------- Public Methods
065:
066: /**
067: * Clear facade.
068: */
069: public void clear() {
070: request = null;
071: }
072:
073: // ------------------------------------------------- ServletRequest Methods
074:
075: public Object getAttribute(String name) {
076: return request.getAttribute(name);
077: }
078:
079: public Enumeration getAttributeNames() {
080: return request.getAttributeNames();
081: }
082:
083: public String getCharacterEncoding() {
084: return request.getCharacterEncoding();
085: }
086:
087: public void setCharacterEncoding(String env)
088: throws java.io.UnsupportedEncodingException {
089: request.setCharacterEncoding(env);
090: }
091:
092: public int getContentLength() {
093: return request.getContentLength();
094: }
095:
096: public String getContentType() {
097: return request.getContentType();
098: }
099:
100: public ServletInputStream getInputStream() throws IOException {
101: return request.getInputStream();
102: }
103:
104: public String getParameter(String name) {
105: return request.getParameter(name);
106: }
107:
108: public Enumeration getParameterNames() {
109: return request.getParameterNames();
110: }
111:
112: public String[] getParameterValues(String name) {
113: return request.getParameterValues(name);
114: }
115:
116: public Map getParameterMap() {
117: return request.getParameterMap();
118: }
119:
120: public String getProtocol() {
121: return request.getProtocol();
122: }
123:
124: public String getScheme() {
125: return request.getScheme();
126: }
127:
128: public String getServerName() {
129: return request.getServerName();
130: }
131:
132: public int getServerPort() {
133: return request.getServerPort();
134: }
135:
136: public BufferedReader getReader() throws IOException {
137: return request.getReader();
138: }
139:
140: public String getRemoteAddr() {
141: return request.getRemoteAddr();
142: }
143:
144: public String getRemoteHost() {
145: return request.getRemoteHost();
146: }
147:
148: public void setAttribute(String name, Object o) {
149: request.setAttribute(name, o);
150: }
151:
152: public void removeAttribute(String name) {
153: request.removeAttribute(name);
154: }
155:
156: public Locale getLocale() {
157: return request.getLocale();
158: }
159:
160: public Enumeration getLocales() {
161: return request.getLocales();
162: }
163:
164: public boolean isSecure() {
165: return request.isSecure();
166: }
167:
168: public RequestDispatcher getRequestDispatcher(String path) {
169: // TODO : Facade !!
170: return request.getRequestDispatcher(path);
171: }
172:
173: public String getRealPath(String path) {
174: return request.getRealPath(path);
175: }
176:
177: /**
178: * Returns the Internet Protocol (IP) source port of the client
179: * or last proxy that sent the request.
180: */
181: public int getRemotePort() {
182: return request.getRemotePort();
183: }
184:
185: /**
186: * Returns the host name of the Internet Protocol (IP) interface on
187: * which the request was received.
188: */
189: public String getLocalName() {
190: return request.getLocalName();
191: }
192:
193: /**
194: * Returns the Internet Protocol (IP) address of the interface on
195: * which the request was received.
196: */
197: public String getLocalAddr() {
198: return request.getLocalAddr();
199: }
200:
201: /**
202: * Returns the Internet Protocol (IP) port number of the interface
203: * on which the request was received.
204: */
205: public int getLocalPort() {
206: return request.getLocalPort();
207: }
208: }
|