|
|||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
HttpServletResponseWrapper.java | - | 0% | 0% | 0% |
|
1 | /* | |
2 | * Copyright 2004 The Apache Software Foundation | |
3 | * | |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | * you may not use this file except in compliance with the License. | |
6 | * You may obtain a copy of the License at | |
7 | * | |
8 | * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | * | |
10 | * Unless required by applicable law or agreed to in writing, software | |
11 | * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | * See the License for the specific language governing permissions and | |
14 | * limitations under the License. | |
15 | */ | |
16 | package javax.servlet.http; | |
17 | ||
18 | import java.io.IOException; | |
19 | ||
20 | import javax.servlet.ServletResponseWrapper; | |
21 | ||
22 | /** | |
23 | * | |
24 | * Provides a convenient implementation of the HttpServletResponse interface that | |
25 | * can be subclassed by developers wishing to adapt the response from a Servlet. | |
26 | * This class implements the Wrapper or Decorator pattern. Methods default to | |
27 | * calling through to the wrapped response object. | |
28 | * | |
29 | * @author Various | |
30 | * @version $Version$ | |
31 | * @since v 2.3 | |
32 | * | |
33 | * @see javax.servlet.http.HttpServletResponse | |
34 | * | |
35 | */ | |
36 | ||
37 | public class HttpServletResponseWrapper extends ServletResponseWrapper implements HttpServletResponse { | |
38 | ||
39 | ||
40 | /** | |
41 | * Constructs a response adaptor wrapping the given response. | |
42 | * @throws java.lang.IllegalArgumentException if the response is null | |
43 | */ | |
44 | 0 | public HttpServletResponseWrapper(HttpServletResponse response) { |
45 | 0 | super(response); |
46 | } | |
47 | ||
48 | 0 | private HttpServletResponse _getHttpServletResponse() { |
49 | 0 | return (HttpServletResponse) super.getResponse(); |
50 | } | |
51 | ||
52 | /** | |
53 | * The default behavior of this method is to call addCookie(Cookie cookie) | |
54 | * on the wrapped response object. | |
55 | */ | |
56 | 0 | public void addCookie(Cookie cookie) { |
57 | 0 | this._getHttpServletResponse().addCookie(cookie); |
58 | } | |
59 | ||
60 | /** | |
61 | * The default behavior of this method is to call containsHeader(String name) | |
62 | * on the wrapped response object. | |
63 | */ | |
64 | ||
65 | ||
66 | 0 | public boolean containsHeader(String name) { |
67 | 0 | return this._getHttpServletResponse().containsHeader(name); |
68 | } | |
69 | ||
70 | /** | |
71 | * The default behavior of this method is to call encodeURL(String url) | |
72 | * on the wrapped response object. | |
73 | */ | |
74 | 0 | public String encodeURL(String url) { |
75 | 0 | return this._getHttpServletResponse().encodeURL(url); |
76 | } | |
77 | ||
78 | /** | |
79 | * The default behavior of this method is to return encodeRedirectURL(String url) | |
80 | * on the wrapped response object. | |
81 | */ | |
82 | 0 | public String encodeRedirectURL(String url) { |
83 | 0 | return this._getHttpServletResponse().encodeRedirectURL(url); |
84 | } | |
85 | ||
86 | /** | |
87 | * The default behavior of this method is to call encodeUrl(String url) | |
88 | * on the wrapped response object. | |
89 | */ | |
90 | 0 | public String encodeUrl(String url) { |
91 | 0 | return this._getHttpServletResponse().encodeUrl(url); |
92 | } | |
93 | ||
94 | /** | |
95 | * The default behavior of this method is to return encodeRedirectUrl(String url) | |
96 | * on the wrapped response object. | |
97 | */ | |
98 | 0 | public String encodeRedirectUrl(String url) { |
99 | 0 | return this._getHttpServletResponse().encodeRedirectUrl(url); |
100 | } | |
101 | ||
102 | /** | |
103 | * The default behavior of this method is to call sendError(int sc, String msg) | |
104 | * on the wrapped response object. | |
105 | */ | |
106 | 0 | public void sendError(int sc, String msg) throws IOException { |
107 | 0 | this._getHttpServletResponse().sendError(sc, msg); |
108 | } | |
109 | ||
110 | /** | |
111 | * The default behavior of this method is to call sendError(int sc) | |
112 | * on the wrapped response object. | |
113 | */ | |
114 | ||
115 | ||
116 | 0 | public void sendError(int sc) throws IOException { |
117 | 0 | this._getHttpServletResponse().sendError(sc); |
118 | } | |
119 | ||
120 | /** | |
121 | * The default behavior of this method is to return sendRedirect(String location) | |
122 | * on the wrapped response object. | |
123 | */ | |
124 | 0 | public void sendRedirect(String location) throws IOException { |
125 | 0 | this._getHttpServletResponse().sendRedirect(location); |
126 | } | |
127 | ||
128 | /** | |
129 | * The default behavior of this method is to call setDateHeader(String name, long date) | |
130 | * on the wrapped response object. | |
131 | */ | |
132 | 0 | public void setDateHeader(String name, long date) { |
133 | 0 | this._getHttpServletResponse().setDateHeader(name, date); |
134 | } | |
135 | ||
136 | /** | |
137 | * The default behavior of this method is to call addDateHeader(String name, long date) | |
138 | * on the wrapped response object. | |
139 | */ | |
140 | 0 | public void addDateHeader(String name, long date) { |
141 | 0 | this._getHttpServletResponse().addDateHeader(name, date); |
142 | } | |
143 | ||
144 | /** | |
145 | * The default behavior of this method is to return setHeader(String name, String value) | |
146 | * on the wrapped response object. | |
147 | */ | |
148 | 0 | public void setHeader(String name, String value) { |
149 | 0 | this._getHttpServletResponse().setHeader(name, value); |
150 | } | |
151 | ||
152 | /** | |
153 | * The default behavior of this method is to return addHeader(String name, String value) | |
154 | * on the wrapped response object. | |
155 | */ | |
156 | 0 | public void addHeader(String name, String value) { |
157 | 0 | this._getHttpServletResponse().addHeader(name, value); |
158 | } | |
159 | ||
160 | /** | |
161 | * The default behavior of this method is to call setIntHeader(String name, int value) | |
162 | * on the wrapped response object. | |
163 | */ | |
164 | 0 | public void setIntHeader(String name, int value) { |
165 | 0 | this._getHttpServletResponse().setIntHeader(name, value); |
166 | } | |
167 | ||
168 | /** | |
169 | * The default behavior of this method is to call addIntHeader(String name, int value) | |
170 | * on the wrapped response object. | |
171 | */ | |
172 | 0 | public void addIntHeader(String name, int value) { |
173 | 0 | this._getHttpServletResponse().addIntHeader(name, value); |
174 | } | |
175 | ||
176 | /** | |
177 | * The default behavior of this method is to call setStatus(int sc) | |
178 | * on the wrapped response object. | |
179 | */ | |
180 | ||
181 | ||
182 | 0 | public void setStatus(int sc) { |
183 | 0 | this._getHttpServletResponse().setStatus(sc); |
184 | } | |
185 | ||
186 | /** | |
187 | * The default behavior of this method is to call setStatus(int sc, String sm) | |
188 | * on the wrapped response object. | |
189 | */ | |
190 | 0 | public void setStatus(int sc, String sm) { |
191 | 0 | this._getHttpServletResponse().setStatus(sc, sm); |
192 | } | |
193 | ||
194 | ||
195 | } |
|