001 /*
002 * Copyright 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 package javax.servlet.http;
017
018 import javax.servlet.ServletRequestWrapper;
019 import java.util.Enumeration;
020
021 /**
022 *
023 * Provides a convenient implementation of the HttpServletRequest interface that
024 * can be subclassed by developers wishing to adapt the request to a Servlet.
025 * This class implements the Wrapper or Decorator pattern. Methods default to
026 * calling through to the wrapped request object.
027 *
028 *
029 * @see javax.servlet.http.HttpServletRequest
030 * @since v 2.3
031 *
032 */
033
034 public class HttpServletRequestWrapper extends ServletRequestWrapper
035 implements HttpServletRequest {
036
037 /**
038 * Constructs a request object wrapping the given request.
039 * @throws java.lang.IllegalArgumentException if the request is null
040 */
041 public HttpServletRequestWrapper(HttpServletRequest request) {
042 super (request);
043 }
044
045 private HttpServletRequest _getHttpServletRequest() {
046 return (HttpServletRequest) super .getRequest();
047 }
048
049 /**
050 * The default behavior of this method is to return getAuthType()
051 * on the wrapped request object.
052 */
053
054 public String getAuthType() {
055 return this ._getHttpServletRequest().getAuthType();
056 }
057
058 /**
059 * The default behavior of this method is to return getCookies()
060 * on the wrapped request object.
061 */
062 public Cookie[] getCookies() {
063 return this ._getHttpServletRequest().getCookies();
064 }
065
066 /**
067 * The default behavior of this method is to return getDateHeader(String name)
068 * on the wrapped request object.
069 */
070 public long getDateHeader(String name) {
071 return this ._getHttpServletRequest().getDateHeader(name);
072 }
073
074 /**
075 * The default behavior of this method is to return getHeader(String name)
076 * on the wrapped request object.
077 */
078 public String getHeader(String name) {
079 return this ._getHttpServletRequest().getHeader(name);
080 }
081
082 /**
083 * The default behavior of this method is to return getHeaders(String name)
084 * on the wrapped request object.
085 */
086 public Enumeration getHeaders(String name) {
087 return this ._getHttpServletRequest().getHeaders(name);
088 }
089
090 /**
091 * The default behavior of this method is to return getHeaderNames()
092 * on the wrapped request object.
093 */
094
095 public Enumeration getHeaderNames() {
096 return this ._getHttpServletRequest().getHeaderNames();
097 }
098
099 /**
100 * The default behavior of this method is to return getIntHeader(String name)
101 * on the wrapped request object.
102 */
103
104 public int getIntHeader(String name) {
105 return this ._getHttpServletRequest().getIntHeader(name);
106 }
107
108 /**
109 * The default behavior of this method is to return getMethod()
110 * on the wrapped request object.
111 */
112 public String getMethod() {
113 return this ._getHttpServletRequest().getMethod();
114 }
115
116 /**
117 * The default behavior of this method is to return getPathInfo()
118 * on the wrapped request object.
119 */
120 public String getPathInfo() {
121 return this ._getHttpServletRequest().getPathInfo();
122 }
123
124 /**
125 * The default behavior of this method is to return getPathTranslated()
126 * on the wrapped request object.
127 */
128
129 public String getPathTranslated() {
130 return this ._getHttpServletRequest().getPathTranslated();
131 }
132
133 /**
134 * The default behavior of this method is to return getContextPath()
135 * on the wrapped request object.
136 */
137 public String getContextPath() {
138 return this ._getHttpServletRequest().getContextPath();
139 }
140
141 /**
142 * The default behavior of this method is to return getQueryString()
143 * on the wrapped request object.
144 */
145 public String getQueryString() {
146 return this ._getHttpServletRequest().getQueryString();
147 }
148
149 /**
150 * The default behavior of this method is to return getRemoteUser()
151 * on the wrapped request object.
152 */
153 public String getRemoteUser() {
154 return this ._getHttpServletRequest().getRemoteUser();
155 }
156
157 /**
158 * The default behavior of this method is to return isUserInRole(String role)
159 * on the wrapped request object.
160 */
161 public boolean isUserInRole(String role) {
162 return this ._getHttpServletRequest().isUserInRole(role);
163 }
164
165 /**
166 * The default behavior of this method is to return getUserPrincipal()
167 * on the wrapped request object.
168 */
169 public java.security.Principal getUserPrincipal() {
170 return this ._getHttpServletRequest().getUserPrincipal();
171 }
172
173 /**
174 * The default behavior of this method is to return getRequestedSessionId()
175 * on the wrapped request object.
176 */
177 public String getRequestedSessionId() {
178 return this ._getHttpServletRequest().getRequestedSessionId();
179 }
180
181 /**
182 * The default behavior of this method is to return getRequestURI()
183 * on the wrapped request object.
184 */
185 public String getRequestURI() {
186 return this ._getHttpServletRequest().getRequestURI();
187 }
188
189 /**
190 * The default behavior of this method is to return getRequestURL()
191 * on the wrapped request object.
192 */
193 public StringBuffer getRequestURL() {
194 return this ._getHttpServletRequest().getRequestURL();
195 }
196
197 /**
198 * The default behavior of this method is to return getServletPath()
199 * on the wrapped request object.
200 */
201 public String getServletPath() {
202 return this ._getHttpServletRequest().getServletPath();
203 }
204
205 /**
206 * The default behavior of this method is to return getSession(boolean create)
207 * on the wrapped request object.
208 */
209 public HttpSession getSession(boolean create) {
210 return this ._getHttpServletRequest().getSession(create);
211 }
212
213 /**
214 * The default behavior of this method is to return getSession()
215 * on the wrapped request object.
216 */
217 public HttpSession getSession() {
218 return this ._getHttpServletRequest().getSession();
219 }
220
221 /**
222 * The default behavior of this method is to return isRequestedSessionIdValid()
223 * on the wrapped request object.
224 */
225
226 public boolean isRequestedSessionIdValid() {
227 return this ._getHttpServletRequest()
228 .isRequestedSessionIdValid();
229 }
230
231 /**
232 * The default behavior of this method is to return isRequestedSessionIdFromCookie()
233 * on the wrapped request object.
234 */
235 public boolean isRequestedSessionIdFromCookie() {
236 return this ._getHttpServletRequest()
237 .isRequestedSessionIdFromCookie();
238 }
239
240 /**
241 * The default behavior of this method is to return isRequestedSessionIdFromURL()
242 * on the wrapped request object.
243 */
244 public boolean isRequestedSessionIdFromURL() {
245 return this ._getHttpServletRequest()
246 .isRequestedSessionIdFromURL();
247 }
248
249 /**
250 * The default behavior of this method is to return isRequestedSessionIdFromUrl()
251 * on the wrapped request object.
252 */
253 public boolean isRequestedSessionIdFromUrl() {
254 return this._getHttpServletRequest()
255 .isRequestedSessionIdFromUrl();
256 }
257
258 }
|