01: /*
02: * Copyright 2003-2006 Rick Knowles <winstone-devel at lists sourceforge net>
03: * Distributed under the terms of either:
04: * - the common development and distribution license (CDDL), v1.0; or
05: * - the GNU Lesser General Public License, v2.1 or later
06: */
07: package javax.servlet;
08:
09: import java.util.Locale;
10: import java.io.IOException;
11:
12: /**
13: * Wraps a servlet response object using the decorator pattern
14: *
15: * @author <a href="mailto:rick_knowles@hotmail.com">Rick Knowles</a>
16: */
17: public class ServletResponseWrapper implements ServletResponse {
18: private ServletResponse response;
19:
20: public ServletResponseWrapper(ServletResponse response) {
21: setResponse(response);
22: }
23:
24: public ServletResponse getResponse() {
25: return this .response;
26: }
27:
28: public void setResponse(ServletResponse response) {
29: if (response == null) {
30: throw new IllegalArgumentException("Response was null");
31: }
32: this .response = response;
33: }
34:
35: public Locale getLocale() {
36: return this .response.getLocale();
37: }
38:
39: public void setLocale(Locale loc) {
40: this .response.setLocale(loc);
41: }
42:
43: public ServletOutputStream getOutputStream() throws IOException {
44: return this .response.getOutputStream();
45: }
46:
47: public java.io.PrintWriter getWriter() throws IOException {
48: return this .response.getWriter();
49: }
50:
51: public boolean isCommitted() {
52: return this .response.isCommitted();
53: }
54:
55: public int getBufferSize() {
56: return this .response.getBufferSize();
57: }
58:
59: public void setBufferSize(int size) {
60: this .response.setBufferSize(size);
61: }
62:
63: public void reset() {
64: this .response.reset();
65: }
66:
67: public void resetBuffer() {
68: this .response.resetBuffer();
69: }
70:
71: public void flushBuffer() throws IOException {
72: this .response.flushBuffer();
73: }
74:
75: public void setContentLength(int len) {
76: this .response.setContentLength(len);
77: }
78:
79: public void setContentType(String type) {
80: this .response.setContentType(type);
81: }
82:
83: public String getContentType() {
84: return this .response.getContentType();
85: }
86:
87: public String getCharacterEncoding() {
88: return this .response.getCharacterEncoding();
89: }
90:
91: public void setCharacterEncoding(String charset) {
92: this.response.setCharacterEncoding(charset);
93: }
94: }
|