]> WPIA git - gigi.git/blob - lib/servlet-api/javax/servlet/http/HttpServletResponseWrapper.java
adding servlet api (from tomcat)
[gigi.git] / lib / servlet-api / javax / servlet / http / HttpServletResponseWrapper.java
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements.  See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License.  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 package javax.servlet.http;
18
19 import java.io.IOException;
20 import java.util.Collection;
21
22 import javax.servlet.ServletResponseWrapper;
23
24 /**
25  * Provides a convenient implementation of the HttpServletResponse interface
26  * that can be subclassed by developers wishing to adapt the response from a
27  * Servlet. This class implements the Wrapper or Decorator pattern. Methods
28  * default to calling through to the wrapped response object.
29  *
30  * @since v 2.3
31  * @see javax.servlet.http.HttpServletResponse
32  */
33 public class HttpServletResponseWrapper extends ServletResponseWrapper
34         implements HttpServletResponse {
35
36     /**
37      * Constructs a response adaptor wrapping the given response.
38      *
39      * @throws java.lang.IllegalArgumentException
40      *             if the response is null
41      */
42     public HttpServletResponseWrapper(HttpServletResponse response) {
43         super(response);
44     }
45
46     private HttpServletResponse _getHttpServletResponse() {
47         return (HttpServletResponse) super.getResponse();
48     }
49
50     /**
51      * The default behavior of this method is to call addCookie(Cookie cookie)
52      * on the wrapped response object.
53      */
54     @Override
55     public void addCookie(Cookie cookie) {
56         this._getHttpServletResponse().addCookie(cookie);
57     }
58
59     /**
60      * The default behavior of this method is to call containsHeader(String
61      * name) on the wrapped response object.
62      */
63     @Override
64     public boolean containsHeader(String name) {
65         return this._getHttpServletResponse().containsHeader(name);
66     }
67
68     /**
69      * The default behavior of this method is to call encodeURL(String url) on
70      * the wrapped response object.
71      */
72     @Override
73     public String encodeURL(String url) {
74         return this._getHttpServletResponse().encodeURL(url);
75     }
76
77     /**
78      * The default behavior of this method is to return encodeRedirectURL(String
79      * url) on the wrapped response object.
80      */
81     @Override
82     public String encodeRedirectURL(String url) {
83         return this._getHttpServletResponse().encodeRedirectURL(url);
84     }
85
86     /**
87      * The default behavior of this method is to call encodeUrl(String url) on
88      * the wrapped response object.
89      *
90      * @deprecated As of Version 3.0 of the Java Servlet API
91      */
92     @Override
93     @SuppressWarnings("dep-ann")
94     // Spec API does not use @Deprecated
95     public String encodeUrl(String url) {
96         return this._getHttpServletResponse().encodeUrl(url);
97     }
98
99     /**
100      * The default behavior of this method is to return encodeRedirectUrl(String
101      * url) on the wrapped response object.
102      *
103      * @deprecated As of Version 3.0 of the Java Servlet API
104      */
105     @Override
106     @SuppressWarnings("dep-ann")
107     // Spec API does not use @Deprecated
108     public String encodeRedirectUrl(String url) {
109         return this._getHttpServletResponse().encodeRedirectUrl(url);
110     }
111
112     /**
113      * The default behavior of this method is to call sendError(int sc, String
114      * msg) on the wrapped response object.
115      */
116     @Override
117     public void sendError(int sc, String msg) throws IOException {
118         this._getHttpServletResponse().sendError(sc, msg);
119     }
120
121     /**
122      * The default behavior of this method is to call sendError(int sc) on the
123      * wrapped response object.
124      */
125     @Override
126     public void sendError(int sc) throws IOException {
127         this._getHttpServletResponse().sendError(sc);
128     }
129
130     /**
131      * The default behavior of this method is to return sendRedirect(String
132      * location) on the wrapped response object.
133      */
134     @Override
135     public void sendRedirect(String location) throws IOException {
136         this._getHttpServletResponse().sendRedirect(location);
137     }
138
139     /**
140      * The default behavior of this method is to call setDateHeader(String name,
141      * long date) on the wrapped response object.
142      */
143     @Override
144     public void setDateHeader(String name, long date) {
145         this._getHttpServletResponse().setDateHeader(name, date);
146     }
147
148     /**
149      * The default behavior of this method is to call addDateHeader(String name,
150      * long date) on the wrapped response object.
151      */
152     @Override
153     public void addDateHeader(String name, long date) {
154         this._getHttpServletResponse().addDateHeader(name, date);
155     }
156
157     /**
158      * The default behavior of this method is to return setHeader(String name,
159      * String value) on the wrapped response object.
160      */
161     @Override
162     public void setHeader(String name, String value) {
163         this._getHttpServletResponse().setHeader(name, value);
164     }
165
166     /**
167      * The default behavior of this method is to return addHeader(String name,
168      * String value) on the wrapped response object.
169      */
170     @Override
171     public void addHeader(String name, String value) {
172         this._getHttpServletResponse().addHeader(name, value);
173     }
174
175     /**
176      * The default behavior of this method is to call setIntHeader(String name,
177      * int value) on the wrapped response object.
178      */
179     @Override
180     public void setIntHeader(String name, int value) {
181         this._getHttpServletResponse().setIntHeader(name, value);
182     }
183
184     /**
185      * The default behavior of this method is to call addIntHeader(String name,
186      * int value) on the wrapped response object.
187      */
188     @Override
189     public void addIntHeader(String name, int value) {
190         this._getHttpServletResponse().addIntHeader(name, value);
191     }
192
193     /**
194      * The default behavior of this method is to call setStatus(int sc) on the
195      * wrapped response object.
196      */
197     @Override
198     public void setStatus(int sc) {
199         this._getHttpServletResponse().setStatus(sc);
200     }
201
202     /**
203      * The default behavior of this method is to call setStatus(int sc, String
204      * sm) on the wrapped response object.
205      *
206      * @deprecated As of Version 3.0 of the Java Servlet API
207      */
208     @Override
209     @SuppressWarnings("dep-ann")
210     // Spec API does not use @Deprecated
211     public void setStatus(int sc, String sm) {
212         this._getHttpServletResponse().setStatus(sc, sm);
213     }
214
215     /**
216      * {@inheritDoc}
217      * <p>
218      * The default implementation is to call
219      * {@link HttpServletResponse#getStatus()}
220      * on the wrapper {@link HttpServletResponse}.
221      *
222      * @since Servlet 3.0
223      */
224     @Override
225     public int getStatus() {
226         return this._getHttpServletResponse().getStatus();
227     }
228
229     /**
230      * {@inheritDoc}
231      * <p>
232      * The default implementation is to call
233      * {@link HttpServletResponse#getHeader(String)}
234      * on the wrapper {@link HttpServletResponse}.
235      *
236      * @since Servlet 3.0
237      */
238     @Override
239     public String getHeader(String name) {
240         return this._getHttpServletResponse().getHeader(name);
241     }
242
243     /**
244      * {@inheritDoc}
245      * <p>
246      * The default implementation is to call
247      * {@link HttpServletResponse#getHeaders(String)}
248      * on the wrapper {@link HttpServletResponse}.
249      *
250      * @since Servlet 3.0
251      */
252     @Override
253     public Collection<String> getHeaders(String name) {
254         return this._getHttpServletResponse().getHeaders(name);
255     }
256
257     /**
258      * {@inheritDoc}
259      * <p>
260      * The default implementation is to call
261      * {@link HttpServletResponse#getHeaderNames()}
262      * on the wrapper {@link HttpServletResponse}.
263      *
264      * @since Servlet 3.0
265      */
266     @Override
267     public Collection<String> getHeaderNames() {
268         return this._getHttpServletResponse().getHeaderNames();
269     }
270 }