Save This Page
Home » glassfish-v2ur2-b04-src » javax » servlet » http » [javadoc | source]
    1   
    2   
    3   /*
    4    * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    5    * 
    6    * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
    7    * 
    8    * Portions Copyright Apache Software Foundation.
    9    * 
   10    * The contents of this file are subject to the terms of either the GNU
   11    * General Public License Version 2 only ("GPL") or the Common Development
   12    * and Distribution License("CDDL") (collectively, the "License").  You
   13    * may not use this file except in compliance with the License. You can obtain
   14    * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
   15    * or glassfish/bootstrap/legal/LICENSE.txt.  See the License for the specific
   16    * language governing permissions and limitations under the License.
   17    * 
   18    * When distributing the software, include this License Header Notice in each
   19    * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
   20    * Sun designates this particular file as subject to the "Classpath" exception
   21    * as provided by Sun in the GPL Version 2 section of the License file that
   22    * accompanied this code.  If applicable, add the following below the License
   23    * Header, with the fields enclosed by brackets [] replaced by your own
   24    * identifying information: "Portions Copyrighted [year]
   25    * [name of copyright owner]"
   26    * 
   27    * Contributor(s):
   28    * 
   29    * If you wish your version of this file to be governed by only the CDDL or
   30    * only the GPL Version 2, indicate your decision by adding "[Contributor]
   31    * elects to include this software in this distribution under the [CDDL or GPL
   32    * Version 2] license."  If you don't indicate a single choice of license, a
   33    * recipient has the option to distribute your version of this file under
   34    * either the CDDL, the GPL Version 2 or to extend the choice of license to
   35    * its licensees as provided above.  However, if you add GPL Version 2 code
   36    * and therefore, elected the GPL Version 2 license, then the option applies
   37    * only if the new code is made subject to such option by the copyright
   38    * holder.
   39    */
   40   
   41   package javax.servlet.http;
   42   
   43   import java.io.IOException;
   44   
   45   import javax.servlet.ServletResponseWrapper;
   46   
   47   /**
   48    * 
   49    * Provides a convenient implementation of the HttpServletResponse interface that
   50    * can be subclassed by developers wishing to adapt the response from a Servlet.
   51    * This class implements the Wrapper or Decorator pattern. Methods default to
   52    * calling through to the wrapped response object.
   53    * 
   54    * @author 	Various
   55    * @since	v 2.3
   56    *
   57    * @see 	javax.servlet.http.HttpServletResponse
   58    *
   59    */
   60   
   61   public class HttpServletResponseWrapper extends ServletResponseWrapper implements HttpServletResponse {
   62   
   63   
   64       /** 
   65       * Constructs a response adaptor wrapping the given response.
   66       * @throws java.lang.IllegalArgumentException if the response is null
   67       */
   68       public HttpServletResponseWrapper(HttpServletResponse response) {
   69   	    super(response);
   70       }
   71       
   72       private HttpServletResponse _getHttpServletResponse() {
   73   	return (HttpServletResponse) super.getResponse();
   74       }
   75       
   76       /**
   77        * The default behavior of this method is to call addCookie(Cookie cookie)
   78        * on the wrapped response object.
   79        */
   80       public void addCookie(Cookie cookie) {
   81   	this._getHttpServletResponse().addCookie(cookie);
   82       }
   83   
   84       /**
   85        * The default behavior of this method is to call containsHeader(String name)
   86        * on the wrapped response object.
   87        */
   88   
   89    
   90       public boolean containsHeader(String name) {
   91   	return this._getHttpServletResponse().containsHeader(name);
   92       }
   93       
   94       /**
   95        * The default behavior of this method is to call encodeURL(String url)
   96        * on the wrapped response object.
   97        */
   98       public String encodeURL(String url) {
   99   	return this._getHttpServletResponse().encodeURL(url);
  100       }
  101   
  102       /**
  103        * The default behavior of this method is to return encodeRedirectURL(String url)
  104        * on the wrapped response object.
  105        */
  106       public String encodeRedirectURL(String url) {
  107   	return this._getHttpServletResponse().encodeRedirectURL(url);
  108       }
  109   
  110       /**
  111        * The default behavior of this method is to call encodeUrl(String url)
  112        * on the wrapped response object.
  113        */
  114       public String encodeUrl(String url) {
  115   	return this._getHttpServletResponse().encodeUrl(url);
  116       }
  117       
  118       /**
  119        * The default behavior of this method is to return encodeRedirectUrl(String url)
  120        * on the wrapped response object.
  121        */
  122       public String encodeRedirectUrl(String url) {
  123   	return this._getHttpServletResponse().encodeRedirectUrl(url);
  124       }
  125       
  126       /**
  127        * The default behavior of this method is to call sendError(int sc, String msg)
  128        * on the wrapped response object.
  129        */
  130       public void sendError(int sc, String msg) throws IOException {
  131   	this._getHttpServletResponse().sendError(sc, msg);
  132       }
  133   
  134       /**
  135        * The default behavior of this method is to call sendError(int sc)
  136        * on the wrapped response object.
  137        */
  138   
  139   
  140       public void sendError(int sc) throws IOException {
  141   	this._getHttpServletResponse().sendError(sc);
  142       }
  143   
  144       /**
  145        * The default behavior of this method is to return sendRedirect(String location)
  146        * on the wrapped response object.
  147        */
  148       public void sendRedirect(String location) throws IOException {
  149   	this._getHttpServletResponse().sendRedirect(location);
  150       }
  151       
  152       /**
  153        * The default behavior of this method is to call setDateHeader(String name, long date)
  154        * on the wrapped response object.
  155        */
  156       public void setDateHeader(String name, long date) {
  157   	this._getHttpServletResponse().setDateHeader(name, date);
  158       }
  159       
  160       /**
  161        * The default behavior of this method is to call addDateHeader(String name, long date)
  162        * on the wrapped response object.
  163        */
  164      public void addDateHeader(String name, long date) {
  165   	this._getHttpServletResponse().addDateHeader(name, date);
  166       }
  167       
  168       /**
  169        * The default behavior of this method is to return setHeader(String name, String value)
  170        * on the wrapped response object.
  171        */
  172       public void setHeader(String name, String value) {
  173   	this._getHttpServletResponse().setHeader(name, value);
  174       }
  175       
  176       /**
  177        * The default behavior of this method is to return addHeader(String name, String value)
  178        * on the wrapped response object.
  179        */
  180        public void addHeader(String name, String value) {
  181   	this._getHttpServletResponse().addHeader(name, value);
  182       }
  183       
  184       /**
  185        * The default behavior of this method is to call setIntHeader(String name, int value)
  186        * on the wrapped response object.
  187        */
  188       public void setIntHeader(String name, int value) {
  189   	this._getHttpServletResponse().setIntHeader(name, value);
  190       }
  191       
  192       /**
  193        * The default behavior of this method is to call addIntHeader(String name, int value)
  194        * on the wrapped response object.
  195        */
  196       public void addIntHeader(String name, int value) {
  197   	this._getHttpServletResponse().addIntHeader(name, value);
  198       }
  199   
  200       /**
  201        * The default behavior of this method is to call setStatus(int sc)
  202        * on the wrapped response object.
  203        */
  204   
  205   
  206       public void setStatus(int sc) {
  207   	this._getHttpServletResponse().setStatus(sc);
  208       }
  209       
  210       /**
  211        * The default behavior of this method is to call setStatus(int sc, String sm)
  212        * on the wrapped response object.
  213        */
  214        public void setStatus(int sc, String sm) {
  215   	this._getHttpServletResponse().setStatus(sc, sm);
  216       }
  217   
  218      
  219   }

Save This Page
Home » glassfish-v2ur2-b04-src » javax » servlet » http » [javadoc | source]