View Javadoc

    1
    2
    3   /*
    4    * The contents of this file are subject to the terms
    5    * of the Common Development and Distribution License
    6    * (the "License").  You may not use this file except
    7    * in compliance with the License.
    8    *
    9    * You can obtain a copy of the license at
    10   * glassfish/bootstrap/legal/CDDLv1.0.txt or
    11   * https://glassfish.dev.java.net/public/CDDLv1.0.html.
    12   * See the License for the specific language governing
    13   * permissions and limitations under the License.
    14   *
    15   * When distributing Covered Code, include this CDDL
    16   * HEADER in each file and include the License file at
    17   * glassfish/bootstrap/legal/CDDLv1.0.txt.  If applicable,
    18   * add the following below this CDDL HEADER, with the
    19   * fields enclosed by brackets "[]" replaced with your
    20   * own identifying information: Portions Copyright [yyyy]
    21   * [name of copyright owner]
    22   *
    23   * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
    24   *
    25   * Portions Copyright Apache Software Foundation.
    26   */
    27
    28  package javax.servlet.http;
    29
    30  import javax.servlet.ServletRequestWrapper;
    31  import java.util.Enumeration;
    32
    33  /**
    34   *
    35   * Provides a convenient implementation of the HttpServletRequest interface that
    36   * can be subclassed by developers wishing to adapt the request to a Servlet.
    37   * This class implements the Wrapper or Decorator pattern. Methods default to
    38   * calling through to the wrapped request object.
    39   *
    40   *
    41   * @see 	javax.servlet.http.HttpServletRequest
    42    * @since	v 2.3
    43   *
    44   */
    45
    46
    47  public class HttpServletRequestWrapper extends ServletRequestWrapper implements HttpServletRequest {
    48
    49  	/**
    50  	* Constructs a request object wrapping the given request.
    51  	* @throws java.lang.IllegalArgumentException if the request is null
    52  	*/
    53      public HttpServletRequestWrapper(HttpServletRequest request) {
    54  	    super(request);
    55      }
    56
    57      private HttpServletRequest _getHttpServletRequest() {
    58  	return (HttpServletRequest) super.getRequest();
    59      }
    60
    61      /**
    62       * The default behavior of this method is to return getAuthType()
    63       * on the wrapped request object.
    64       */
    65
    66      public String getAuthType() {
    67  	return this._getHttpServletRequest().getAuthType();
    68      }
    69
    70      /**
    71       * The default behavior of this method is to return getCookies()
    72       * on the wrapped request object.
    73       */
    74      public Cookie[] getCookies() {
    75  	return this._getHttpServletRequest().getCookies();
    76      }
    77
    78      /**
    79       * The default behavior of this method is to return getDateHeader(String name)
    80       * on the wrapped request object.
    81       */
    82      public long getDateHeader(String name) {
    83  	return this._getHttpServletRequest().getDateHeader(name);
    84      }
    85
    86      /**
    87       * The default behavior of this method is to return getHeader(String name)
    88       * on the wrapped request object.
    89       */
    90      public String getHeader(String name) {
    91  	return this._getHttpServletRequest().getHeader(name);
    92      }
    93
    94      /**
    95       * The default behavior of this method is to return getHeaders(String name)
    96       * on the wrapped request object.
    97       */
    98      public Enumeration getHeaders(String name) {
    99  	return this._getHttpServletRequest().getHeaders(name);
    100     }
    101
    102     /**
    103      * The default behavior of this method is to return getHeaderNames()
    104      * on the wrapped request object.
    105      */
    106
    107     public Enumeration getHeaderNames() {
    108 	return this._getHttpServletRequest().getHeaderNames();
    109     }
    110
    111     /**
    112      * The default behavior of this method is to return getIntHeader(String name)
    113      * on the wrapped request object.
    114      */
    115
    116      public int getIntHeader(String name) {
    117 	return this._getHttpServletRequest().getIntHeader(name);
    118     }
    119
    120     /**
    121      * The default behavior of this method is to return getMethod()
    122      * on the wrapped request object.
    123      */
    124     public String getMethod() {
    125 	return this._getHttpServletRequest().getMethod();
    126     }
    127
    128     /**
    129      * The default behavior of this method is to return getPathInfo()
    130      * on the wrapped request object.
    131      */
    132     public String getPathInfo() {
    133 	return this._getHttpServletRequest().getPathInfo();
    134     }
    135
    136     /**
    137      * The default behavior of this method is to return getPathTranslated()
    138      * on the wrapped request object.
    139      */
    140
    141      public String getPathTranslated() {
    142 	return this._getHttpServletRequest().getPathTranslated();
    143     }
    144
    145     /**
    146      * The default behavior of this method is to return getContextPath()
    147      * on the wrapped request object.
    148      */
    149     public String getContextPath() {
    150 	return this._getHttpServletRequest().getContextPath();
    151     }
    152
    153     /**
    154      * The default behavior of this method is to return getQueryString()
    155      * on the wrapped request object.
    156      */
    157     public String getQueryString() {
    158 	return this._getHttpServletRequest().getQueryString();
    159     }
    160
    161     /**
    162      * The default behavior of this method is to return getRemoteUser()
    163      * on the wrapped request object.
    164      */
    165     public String getRemoteUser() {
    166 	return this._getHttpServletRequest().getRemoteUser();
    167     }
    168
    169
    170     /**
    171      * The default behavior of this method is to return isUserInRole(String role)
    172      * on the wrapped request object.
    173      */
    174     public boolean isUserInRole(String role) {
    175 	return this._getHttpServletRequest().isUserInRole(role);
    176     }
    177
    178
    179
    180     /**
    181      * The default behavior of this method is to return getUserPrincipal()
    182      * on the wrapped request object.
    183      */
    184     public java.security.Principal getUserPrincipal() {
    185 	return this._getHttpServletRequest().getUserPrincipal();
    186     }
    187
    188
    189     /**
    190      * The default behavior of this method is to return getRequestedSessionId()
    191      * on the wrapped request object.
    192      */
    193     public String getRequestedSessionId() {
    194 	return this._getHttpServletRequest().getRequestedSessionId();
    195     }
    196
    197     /**
    198      * The default behavior of this method is to return getRequestURI()
    199      * on the wrapped request object.
    200      */
    201     public String getRequestURI() {
    202 	return this._getHttpServletRequest().getRequestURI();
    203     }
    204 	/**
    205      * The default behavior of this method is to return getRequestURL()
    206      * on the wrapped request object.
    207      */
    208     public StringBuffer getRequestURL() {
    209 	return this._getHttpServletRequest().getRequestURL();
    210     }
    211
    212
    213     /**
    214      * The default behavior of this method is to return getServletPath()
    215      * on the wrapped request object.
    216      */
    217     public String getServletPath() {
    218 	return this._getHttpServletRequest().getServletPath();
    219     }
    220
    221
    222     /**
    223      * The default behavior of this method is to return getSession(boolean create)
    224      * on the wrapped request object.
    225      */
    226     public HttpSession getSession(boolean create) {
    227 	return this._getHttpServletRequest().getSession(create);
    228     }
    229
    230     /**
    231      * The default behavior of this method is to return getSession()
    232      * on the wrapped request object.
    233      */
    234     public HttpSession getSession() {
    235 	return this._getHttpServletRequest().getSession();
    236     }
    237
    238     /**
    239      * The default behavior of this method is to return isRequestedSessionIdValid()
    240      * on the wrapped request object.
    241      */
    242
    243     public boolean isRequestedSessionIdValid() {
    244 	return this._getHttpServletRequest().isRequestedSessionIdValid();
    245     }
    246
    247
    248     /**
    249      * The default behavior of this method is to return isRequestedSessionIdFromCookie()
    250      * on the wrapped request object.
    251      */
    252     public boolean isRequestedSessionIdFromCookie() {
    253 	return this._getHttpServletRequest().isRequestedSessionIdFromCookie();
    254     }
    255
    256     	  /**
    257      * The default behavior of this method is to return isRequestedSessionIdFromURL()
    258      * on the wrapped request object.
    259      */
    260     public boolean isRequestedSessionIdFromURL() {
    261 	return this._getHttpServletRequest().isRequestedSessionIdFromURL();
    262     }
    263
    264     /**
    265      * The default behavior of this method is to return isRequestedSessionIdFromUrl()
    266      * on the wrapped request object.
    267      */
    268     public boolean isRequestedSessionIdFromUrl() {
    269 	return this._getHttpServletRequest().isRequestedSessionIdFromUrl();
    270     }
    271
    272
    273
    274 }