View Javadoc

1   /**
2    *
3    * Copyright 2003-2004 The Apache Software Foundation
4    *
5    *  Licensed under the Apache License, Version 2.0 (the "License");
6    *  you may not use this file except in compliance with the License.
7    *  You may obtain a copy of the License at
8    *
9    *     http://www.apache.org/licenses/LICENSE-2.0
10   *
11   *  Unless required by applicable law or agreed to in writing, software
12   *  distributed under the License is distributed on an "AS IS" BASIS,
13   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   *  See the License for the specific language governing permissions and
15   *  limitations under the License.
16   */
17  
18  //
19  // This source code implements specifications defined by the Java
20  // Community Process. In order to remain compliant with the specification
21  // DO NOT add / change / or delete method signatures!
22  //
23  
24  package javax.servlet.http;
25  
26  import java.util.Enumeration;
27  import javax.servlet.ServletRequestWrapper;
28  
29  /**
30   * Provides a convenient implementation of the HttpServletRequest interface that
31   * can be subclassed by developers wishing to adapt the request to a Servlet.
32   * This class implements the Wrapper or Decorator pattern. Methods default to
33   * calling through to the wrapped request object.
34   *
35   * @see javax.servlet.http.HttpServletRequest
36  
37   * @since Servlet 2.3
38   *
39   * @version $Rev: 46019 $ $Date: 2004-09-14 02:56:06 -0700 (Tue, 14 Sep 2004) $
40   */
41  public class HttpServletRequestWrapper extends ServletRequestWrapper implements HttpServletRequest {
42      /**
43       * Constructs a request object wrapping the given request.
44       * @throws java.lang.IllegalArgumentException if the request is null
45       */
46      public HttpServletRequestWrapper(HttpServletRequest request) {
47          super(request);
48      }
49  
50      private HttpServletRequest _getHttpServletRequest() {
51          return (HttpServletRequest) super.getRequest();
52      }
53  
54      /**
55       * The default behavior of this method is to return getAuthType()
56       * on the wrapped request object.
57       */
58      public String getAuthType() {
59          return this._getHttpServletRequest().getAuthType();
60      }
61  
62      /**
63       * The default behavior of this method is to return getCookies()
64       * on the wrapped request object.
65       */
66      public Cookie[] getCookies() {
67          return this._getHttpServletRequest().getCookies();
68      }
69  
70      /**
71       * The default behavior of this method is to return getDateHeader(String name)
72       * on the wrapped request object.
73       */
74      public long getDateHeader(String name) {
75          return this._getHttpServletRequest().getDateHeader(name);
76      }
77  
78      /**
79       * The default behavior of this method is to return getHeader(String name)
80       * on the wrapped request object.
81       */
82      public String getHeader(String name) {
83          return this._getHttpServletRequest().getHeader(name);
84      }
85  
86      /**
87       * The default behavior of this method is to return getHeaders(String name)
88       * on the wrapped request object.
89       */
90      public Enumeration getHeaders(String name) {
91          return this._getHttpServletRequest().getHeaders(name);
92      }
93  
94      /**
95       * The default behavior of this method is to return getHeaderNames()
96       * on the wrapped request object.
97       */
98      public Enumeration getHeaderNames() {
99          return this._getHttpServletRequest().getHeaderNames();
100     }
101 
102     /**
103      * The default behavior of this method is to return getIntHeader(String name)
104      * on the wrapped request object.
105      */
106     public int getIntHeader(String name) {
107         return this._getHttpServletRequest().getIntHeader(name);
108     }
109 
110     /**
111      * The default behavior of this method is to return getMethod()
112      * on the wrapped request object.
113      */
114     public String getMethod() {
115         return this._getHttpServletRequest().getMethod();
116     }
117 
118     /**
119      * The default behavior of this method is to return getPathInfo()
120      * on the wrapped request object.
121      */
122     public String getPathInfo() {
123         return this._getHttpServletRequest().getPathInfo();
124     }
125 
126     /**
127      * The default behavior of this method is to return getPathTranslated()
128      * on the wrapped request object.
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     public boolean isRequestedSessionIdValid() {
227         return this._getHttpServletRequest().isRequestedSessionIdValid();
228     }
229 
230     /**
231      * The default behavior of this method is to return isRequestedSessionIdFromCookie()
232      * on the wrapped request object.
233      */
234     public boolean isRequestedSessionIdFromCookie() {
235         return this._getHttpServletRequest().isRequestedSessionIdFromCookie();
236     }
237 
238     /**
239      * The default behavior of this method is to return isRequestedSessionIdFromURL()
240      * on the wrapped request object.
241      */
242     public boolean isRequestedSessionIdFromURL() {
243         return this._getHttpServletRequest().isRequestedSessionIdFromURL();
244     }
245 
246     /**
247      * The default behavior of this method is to return isRequestedSessionIdFromUrl()
248      * on the wrapped request object.
249      */
250     public boolean isRequestedSessionIdFromUrl() {
251         return this._getHttpServletRequest().isRequestedSessionIdFromUrl();
252     }
253 }