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    
035    public class HttpServletRequestWrapper extends ServletRequestWrapper 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        /**
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        
168        /**
169         * The default behavior of this method is to return getUserPrincipal()
170         * on the wrapped request object.
171         */
172        public java.security.Principal getUserPrincipal() {
173            return this._getHttpServletRequest().getUserPrincipal();
174        }
175        
176       
177        /**
178         * The default behavior of this method is to return getRequestedSessionId()
179         * on the wrapped request object.
180         */
181        public String getRequestedSessionId() {
182            return this._getHttpServletRequest().getRequestedSessionId();
183        }
184        
185        /**
186         * The default behavior of this method is to return getRequestURI()
187         * on the wrapped request object.
188         */
189        public String getRequestURI() {
190            return this._getHttpServletRequest().getRequestURI();
191        }
192            /**
193         * The default behavior of this method is to return getRequestURL()
194         * on the wrapped request object.
195         */
196        public StringBuffer getRequestURL() {
197            return this._getHttpServletRequest().getRequestURL();
198        }
199            
200        
201        /**
202         * The default behavior of this method is to return getServletPath()
203         * on the wrapped request object.
204         */
205        public String getServletPath() {
206            return this._getHttpServletRequest().getServletPath();
207        }
208        
209        
210        /**
211         * The default behavior of this method is to return getSession(boolean create)
212         * on the wrapped request object.
213         */
214        public HttpSession getSession(boolean create) {
215            return this._getHttpServletRequest().getSession(create);
216        }
217        
218        /**
219         * The default behavior of this method is to return getSession()
220         * on the wrapped request object.
221         */
222        public HttpSession getSession() {
223            return this._getHttpServletRequest().getSession();
224        }
225        
226        /**
227         * The default behavior of this method is to return isRequestedSessionIdValid()
228         * on the wrapped request object.
229         */ 
230    
231        public boolean isRequestedSessionIdValid() {
232            return this._getHttpServletRequest().isRequestedSessionIdValid();
233        }
234         
235        
236        /**
237         * The default behavior of this method is to return isRequestedSessionIdFromCookie()
238         * on the wrapped request object.
239         */
240        public boolean isRequestedSessionIdFromCookie() {
241            return this._getHttpServletRequest().isRequestedSessionIdFromCookie();
242        }
243        
244              /**
245         * The default behavior of this method is to return isRequestedSessionIdFromURL()
246         * on the wrapped request object.
247         */ 
248        public boolean isRequestedSessionIdFromURL() {
249            return this._getHttpServletRequest().isRequestedSessionIdFromURL();
250        }
251        
252        /**
253         * The default behavior of this method is to return isRequestedSessionIdFromUrl()
254         * on the wrapped request object.
255         */
256        public boolean isRequestedSessionIdFromUrl() {
257            return this._getHttpServletRequest().isRequestedSessionIdFromUrl();
258        }
259    
260    
261        
262    }