KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tester > TesterHttpServletResponseWrapper


1 /*
2  * Copyright 1999, 2000 ,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
17 package org.apache.tester;
18
19
20 import java.io.*;
21 import java.util.*;
22 import javax.servlet.*;
23 import javax.servlet.http.*;
24
25 /**
26  * Tester response wrapper that logs all calls to the configured logger,
27  * before passing them on to the underlying response.
28  *
29  * @author Craig R. McClanahan
30  * @version $Revision: 1.2 $ $Date: 2004/02/27 14:58:57 $
31  */

32
33 public class TesterHttpServletResponseWrapper
34     extends HttpServletResponseWrapper {
35
36
37     // ------------------------------------------------------------ Constructor
38

39
40     /**
41      * Configure a new response wrapper.
42      *
43      * @param response The response we are wrapping
44      */

45     public TesterHttpServletResponseWrapper(HttpServletResponse response) {
46
47         super(response);
48
49     }
50
51
52     // --------------------------------------------------------- Public Methods
53

54
55     // For each public method, log the call and pass it to the wrapped response
56

57
58     public void addCookie(Cookie cookie) {
59         StaticLogger.write("TesterHttpServletResponseWrapper.addCookie()");
60         ((HttpServletResponse) getResponse()).addCookie(cookie);
61     }
62
63
64     public void addDateHeader(String JavaDoc name, long value) {
65         StaticLogger.write("TesterHttpServletResponseWrapper.addDateHeader()");
66         ((HttpServletResponse) getResponse()).addDateHeader(name, value);
67     }
68
69
70     public void addHeader(String JavaDoc name, String JavaDoc value) {
71         StaticLogger.write("TesterHttpServletResponseWrapper.addHeader()");
72         ((HttpServletResponse) getResponse()).addHeader(name, value);
73     }
74
75
76     public void addIntHeader(String JavaDoc name, int value) {
77         StaticLogger.write("TesterHttpServletResponseWrapper.addIntHeader()");
78         ((HttpServletResponse) getResponse()).addIntHeader(name, value);
79     }
80
81
82     public boolean containsHeader(String JavaDoc name) {
83         StaticLogger.write("TesterHttpServletResponseWrapper.containsHeader()");
84         return (((HttpServletResponse) getResponse()).containsHeader(name));
85     }
86
87
88     public String JavaDoc encodeURL(String JavaDoc url) {
89         StaticLogger.write("TesterHttpServletResponseWrapper.encodeURL()");
90         return (((HttpServletResponse) getResponse()).encodeURL(url));
91     }
92
93
94     public String JavaDoc encodeUrl(String JavaDoc url) {
95         StaticLogger.write("TesterHttpServletResponseWrapper.encodeUrl()");
96         return (((HttpServletResponse) getResponse()).encodeUrl(url));
97     }
98
99
100     public String JavaDoc encodeRedirectURL(String JavaDoc url) {
101         StaticLogger.write("TesterHttpServletResponseWrapper.encodeRedirectURL()");
102         return (((HttpServletResponse) getResponse()).encodeRedirectURL(url));
103     }
104
105
106     public String JavaDoc encodeRedirectUrl(String JavaDoc url) {
107         StaticLogger.write("TesterHttpServletResponseWrapper.encodeRedirectUrl()");
108         return (((HttpServletResponse) getResponse()).encodeRedirectUrl(url));
109     }
110
111
112     public void flushBuffer() throws IOException {
113         StaticLogger.write("TesterHttpServletResponseWrapper.flushBuffer()");
114         getResponse().flushBuffer();
115     }
116
117
118     public int getBufferSize() {
119         StaticLogger.write("TesterHttpServletResponseWrapper.getBufferSize()");
120         return (getResponse().getBufferSize());
121     }
122
123
124     public String JavaDoc getCharacterEncoding() {
125         StaticLogger.write("TesterHttpServletResponseWrapper.getCharacterEncoding()");
126         return (getResponse().getCharacterEncoding());
127     }
128
129
130     public Locale getLocale() {
131         StaticLogger.write("TesterHttpServletResponseWrapper.getLocale()");
132         return (getResponse().getLocale());
133     }
134
135
136     public ServletOutputStream getOutputStream() throws IOException {
137         StaticLogger.write("TesterHttpServletResponseWrapper.getOutputStream()");
138         return (getResponse().getOutputStream());
139     }
140
141
142     public PrintWriter getWriter() throws IOException {
143         StaticLogger.write("TesterHttpServletResponseWrapper.getWriter()");
144         return (getResponse().getWriter());
145     }
146
147
148     public boolean isCommitted() {
149         StaticLogger.write("TesterHttpServletResponseWrapper.isCommitted()");
150         return (getResponse().isCommitted());
151     }
152
153
154     public void reset() {
155         StaticLogger.write("TesterHttpServletResponseWrapper.reset()");
156         getResponse().reset();
157     }
158
159
160     public void resetBuffer() {
161         StaticLogger.write("TesterHttpServletResponseWrapper.resetBuffer()");
162         getResponse().resetBuffer();
163     }
164
165
166     public void sendError(int sc) throws IOException {
167         StaticLogger.write("TesterHttpServletResponseWrapper.sendError(i)");
168         ((HttpServletResponse) getResponse()).sendError(sc);
169     }
170
171
172     public void sendError(int sc, String JavaDoc msg) throws IOException {
173         StaticLogger.write("TesterHttpServletResponseWrapper.sendError(i,s)");
174         ((HttpServletResponse) getResponse()).sendError(sc, msg);
175     }
176
177
178     public void sendRedirect(String JavaDoc location) throws IOException {
179         StaticLogger.write("TesterHttpServletResponseWrapper.sendRedirect()");
180         ((HttpServletResponse) getResponse()).sendRedirect(location);
181     }
182
183
184     public void setBufferSize(int size) {
185         StaticLogger.write("TesterHttpServletResponseWrapper.setBufferSize()");
186         getResponse().setBufferSize(size);
187     }
188
189
190     public void setContentLength(int len) {
191         StaticLogger.write("TesterHttpServletResponseWrapper.setContentLength()");
192         getResponse().setContentLength(len);
193     }
194
195
196     public void setContentType(String JavaDoc type) {
197         StaticLogger.write("TesterHttpServletResponseWrapper.setContentType()");
198         getResponse().setContentType(type);
199     }
200
201
202     public void setDateHeader(String JavaDoc name, long value) {
203         StaticLogger.write("TesterHttpServletResponseWrapper.setDateHeader()");
204         ((HttpServletResponse) getResponse()).setDateHeader(name, value);
205     }
206
207
208     public void setHeader(String JavaDoc name, String JavaDoc value) {
209         StaticLogger.write("TesterHttpServletResponseWrapper.setHeader()");
210         ((HttpServletResponse) getResponse()).setHeader(name, value);
211     }
212
213
214     public void setIntHeader(String JavaDoc name, int value) {
215         StaticLogger.write("TesterHttpServletResponseWrapper.setIntHeader()");
216         ((HttpServletResponse) getResponse()).setIntHeader(name, value);
217     }
218
219
220     public void setLocale(Locale locale) {
221         StaticLogger.write("TesterHttpServletResponseWrapper.setLocale()");
222         getResponse().setLocale(locale);
223     }
224
225
226     public void setStatus(int sc) {
227         StaticLogger.write("TesterHttpServletResponseWrapper.setStatus(i)");
228         ((HttpServletResponse) getResponse()).setStatus(sc);
229     }
230
231
232     public void setStatus(int sc, String JavaDoc msg) {
233         StaticLogger.write("TesterHttpServletResponseWrapper.setStatus(i,s)");
234         ((HttpServletResponse) getResponse()).setStatus(sc, msg);
235     }
236
237
238 }
239
Popular Tags