001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package javax.servlet.http;
018:
019: import javax.servlet.ServletRequestWrapper;
020: import java.util.Enumeration;
021:
022: /**
023: *
024: * Provides a convenient implementation of the HttpServletRequest interface that
025: * can be subclassed by developers wishing to adapt the request to a Servlet.
026: * This class implements the Wrapper or Decorator pattern. Methods default to
027: * calling through to the wrapped request object.
028: *
029: *
030: * @see javax.servlet.http.HttpServletRequest
031: * @since v 2.3
032: *
033: */
034:
035: public class HttpServletRequestWrapper extends ServletRequestWrapper
036: implements HttpServletRequest {
037:
038: /**
039: * Constructs a request object wrapping the given request.
040: * @throws java.lang.IllegalArgumentException if the request is null
041: */
042: public HttpServletRequestWrapper(HttpServletRequest request) {
043: super (request);
044: }
045:
046: private HttpServletRequest _getHttpServletRequest() {
047: return (HttpServletRequest) super .getRequest();
048: }
049:
050: /**
051: * The default behavior of this method is to return getAuthType()
052: * on the wrapped request object.
053: */
054:
055: public String getAuthType() {
056: return this ._getHttpServletRequest().getAuthType();
057: }
058:
059: /**
060: * The default behavior of this method is to return getCookies()
061: * on the wrapped request object.
062: */
063: public Cookie[] getCookies() {
064: return this ._getHttpServletRequest().getCookies();
065: }
066:
067: /**
068: * The default behavior of this method is to return getDateHeader(String name)
069: * on the wrapped request object.
070: */
071: public long getDateHeader(String name) {
072: return this ._getHttpServletRequest().getDateHeader(name);
073: }
074:
075: /**
076: * The default behavior of this method is to return getHeader(String name)
077: * on the wrapped request object.
078: */
079: public String getHeader(String name) {
080: return this ._getHttpServletRequest().getHeader(name);
081: }
082:
083: /**
084: * The default behavior of this method is to return getHeaders(String name)
085: * on the wrapped request object.
086: */
087: public Enumeration getHeaders(String name) {
088: return this ._getHttpServletRequest().getHeaders(name);
089: }
090:
091: /**
092: * The default behavior of this method is to return getHeaderNames()
093: * on the wrapped request object.
094: */
095:
096: public Enumeration getHeaderNames() {
097: return this ._getHttpServletRequest().getHeaderNames();
098: }
099:
100: /**
101: * The default behavior of this method is to return getIntHeader(String name)
102: * on the wrapped request object.
103: */
104:
105: public int getIntHeader(String name) {
106: return this ._getHttpServletRequest().getIntHeader(name);
107: }
108:
109: /**
110: * The default behavior of this method is to return getMethod()
111: * on the wrapped request object.
112: */
113: public String getMethod() {
114: return this ._getHttpServletRequest().getMethod();
115: }
116:
117: /**
118: * The default behavior of this method is to return getPathInfo()
119: * on the wrapped request object.
120: */
121: public String getPathInfo() {
122: return this ._getHttpServletRequest().getPathInfo();
123: }
124:
125: /**
126: * The default behavior of this method is to return getPathTranslated()
127: * on the wrapped request object.
128: */
129:
130: public String getPathTranslated() {
131: return this ._getHttpServletRequest().getPathTranslated();
132: }
133:
134: /**
135: * The default behavior of this method is to return getContextPath()
136: * on the wrapped request object.
137: */
138: public String getContextPath() {
139: return this ._getHttpServletRequest().getContextPath();
140: }
141:
142: /**
143: * The default behavior of this method is to return getQueryString()
144: * on the wrapped request object.
145: */
146: public String getQueryString() {
147: return this ._getHttpServletRequest().getQueryString();
148: }
149:
150: /**
151: * The default behavior of this method is to return getRemoteUser()
152: * on the wrapped request object.
153: */
154: public String getRemoteUser() {
155: return this ._getHttpServletRequest().getRemoteUser();
156: }
157:
158: /**
159: * The default behavior of this method is to return isUserInRole(String role)
160: * on the wrapped request object.
161: */
162: public boolean isUserInRole(String role) {
163: return this ._getHttpServletRequest().isUserInRole(role);
164: }
165:
166: /**
167: * The default behavior of this method is to return getUserPrincipal()
168: * on the wrapped request object.
169: */
170: public java.security.Principal getUserPrincipal() {
171: return this ._getHttpServletRequest().getUserPrincipal();
172: }
173:
174: /**
175: * The default behavior of this method is to return getRequestedSessionId()
176: * on the wrapped request object.
177: */
178: public String getRequestedSessionId() {
179: return this ._getHttpServletRequest().getRequestedSessionId();
180: }
181:
182: /**
183: * The default behavior of this method is to return getRequestURI()
184: * on the wrapped request object.
185: */
186: public String getRequestURI() {
187: return this ._getHttpServletRequest().getRequestURI();
188: }
189:
190: /**
191: * The default behavior of this method is to return getRequestURL()
192: * on the wrapped request object.
193: */
194: public StringBuffer getRequestURL() {
195: return this ._getHttpServletRequest().getRequestURL();
196: }
197:
198: /**
199: * The default behavior of this method is to return getServletPath()
200: * on the wrapped request object.
201: */
202: public String getServletPath() {
203: return this ._getHttpServletRequest().getServletPath();
204: }
205:
206: /**
207: * The default behavior of this method is to return getSession(boolean create)
208: * on the wrapped request object.
209: */
210: public HttpSession getSession(boolean create) {
211: return this ._getHttpServletRequest().getSession(create);
212: }
213:
214: /**
215: * The default behavior of this method is to return getSession()
216: * on the wrapped request object.
217: */
218: public HttpSession getSession() {
219: return this ._getHttpServletRequest().getSession();
220: }
221:
222: /**
223: * The default behavior of this method is to return isRequestedSessionIdValid()
224: * on the wrapped request object.
225: */
226:
227: public boolean isRequestedSessionIdValid() {
228: return this ._getHttpServletRequest()
229: .isRequestedSessionIdValid();
230: }
231:
232: /**
233: * The default behavior of this method is to return isRequestedSessionIdFromCookie()
234: * on the wrapped request object.
235: */
236: public boolean isRequestedSessionIdFromCookie() {
237: return this ._getHttpServletRequest()
238: .isRequestedSessionIdFromCookie();
239: }
240:
241: /**
242: * The default behavior of this method is to return isRequestedSessionIdFromURL()
243: * on the wrapped request object.
244: */
245: public boolean isRequestedSessionIdFromURL() {
246: return this ._getHttpServletRequest()
247: .isRequestedSessionIdFromURL();
248: }
249:
250: /**
251: * The default behavior of this method is to return isRequestedSessionIdFromUrl()
252: * on the wrapped request object.
253: */
254: public boolean isRequestedSessionIdFromUrl() {
255: return this._getHttpServletRequest()
256: .isRequestedSessionIdFromUrl();
257: }
258:
259: }
|