001: /*
002: * Copyright 2003-2006 Rick Knowles <winstone-devel at lists sourceforge net>
003: * Distributed under the terms of either:
004: * - the common development and distribution license (CDDL), v1.0; or
005: * - the GNU Lesser General Public License, v2.1 or later
006: */
007: package javax.servlet.http;
008:
009: import java.io.IOException;
010:
011: /**
012: * Wraps HttpServletResponse objects in a decorator pattern
013: *
014: * @author <a href="mailto:rick_knowles@hotmail.com">Rick Knowles</a>
015: */
016: public class HttpServletResponseWrapper extends
017: javax.servlet.ServletResponseWrapper implements
018: HttpServletResponse {
019: private HttpServletResponse httpResponse;
020:
021: public HttpServletResponseWrapper(HttpServletResponse response) {
022: super (response);
023: this .httpResponse = response;
024: }
025:
026: public void setResponse(javax.servlet.ServletResponse response) {
027: if (response instanceof HttpServletResponse) {
028: super .setResponse(response);
029: this .httpResponse = (HttpServletResponse) response;
030: } else
031: throw new IllegalArgumentException(
032: "Not an HttpServletResponse");
033: }
034:
035: public void addCookie(Cookie cookie) {
036: this .httpResponse.addCookie(cookie);
037: }
038:
039: public void addDateHeader(String name, long date) {
040: this .httpResponse.addDateHeader(name, date);
041: }
042:
043: public void addHeader(String name, String value) {
044: this .httpResponse.addHeader(name, value);
045: }
046:
047: public void addIntHeader(String name, int value) {
048: this .httpResponse.addIntHeader(name, value);
049: }
050:
051: public boolean containsHeader(String name) {
052: return this .httpResponse.containsHeader(name);
053: }
054:
055: public String encodeRedirectURL(String url) {
056: return this .httpResponse.encodeRedirectURL(url);
057: }
058:
059: public String encodeURL(String url) {
060: return this .httpResponse.encodeURL(url);
061: }
062:
063: public void sendError(int sc) throws IOException {
064: this .httpResponse.sendError(sc);
065: }
066:
067: public void sendError(int sc, String msg) throws IOException {
068: this .httpResponse.sendError(sc, msg);
069: }
070:
071: public void sendRedirect(String location) throws IOException {
072: this .httpResponse.sendRedirect(location);
073: }
074:
075: public void setDateHeader(String name, long date) {
076: this .httpResponse.setDateHeader(name, date);
077: }
078:
079: public void setHeader(String name, String value) {
080: this .httpResponse.setHeader(name, value);
081: }
082:
083: public void setIntHeader(String name, int value) {
084: this .httpResponse.setIntHeader(name, value);
085: }
086:
087: public void setStatus(int sc) {
088: this .httpResponse.setStatus(sc);
089: }
090:
091: /**
092: * @deprecated
093: */
094: public String encodeRedirectUrl(String url) {
095: return this .httpResponse.encodeRedirectUrl(url);
096: }
097:
098: /**
099: * @deprecated
100: */
101: public String encodeUrl(String url) {
102: return this .httpResponse.encodeUrl(url);
103: }
104:
105: /**
106: * @deprecated
107: */
108: public void setStatus(int sc, String sm) {
109: this.httpResponse.setStatus(sc, sm);
110: }
111:
112: }
|