001: /* RenderHttpServletResponse.java
002:
003: {{IS_NOTE
004: Purpose:
005:
006: Description:
007:
008: History:
009: Tue Jan 17 00:59:09 2006, Created by tomyeh
010: }}IS_NOTE
011:
012: Copyright (C) 2006 Potix Corporation. All Rights Reserved.
013:
014: {{IS_RIGHT
015: This program is distributed under GPL Version 2.0 in the hope that
016: it will be useful, but WITHOUT ANY WARRANTY.
017: }}IS_RIGHT
018: */
019: package org.zkoss.web.portlet;
020:
021: import javax.servlet.http.HttpServletResponse;
022: import javax.portlet.RenderResponse;
023:
024: import org.zkoss.web.servlet.ServletOutputStreamWrapper;
025:
026: /**
027: * A facade of RenderResponse that implements HttpServletRespose.
028: *
029: * @author tomyeh
030: */
031: public class RenderHttpServletResponse implements HttpServletResponse {
032: private final RenderResponse _res;
033:
034: public static HttpServletResponse getInstance(RenderResponse res) {
035: if (res instanceof HttpServletResponse)
036: return (HttpServletResponse) res;
037: return new RenderHttpServletResponse(res);
038: }
039:
040: private RenderHttpServletResponse(RenderResponse res) {
041: if (res == null)
042: throw new IllegalArgumentException("null");
043: _res = res;
044: }
045:
046: //-- ServletResponse --//
047: public void flushBuffer() throws java.io.IOException {
048: _res.flushBuffer();
049: }
050:
051: public int getBufferSize() {
052: return _res.getBufferSize();
053: }
054:
055: public String getCharacterEncoding() {
056: return _res.getCharacterEncoding();
057: }
058:
059: public String getContentType() {
060: return _res.getContentType();
061: }
062:
063: public java.util.Locale getLocale() {
064: return _res.getLocale();
065: }
066:
067: public javax.servlet.ServletOutputStream getOutputStream()
068: throws java.io.IOException {
069: return ServletOutputStreamWrapper.getInstance(_res
070: .getPortletOutputStream());
071: }
072:
073: public java.io.PrintWriter getWriter() throws java.io.IOException {
074: //Bug 1548478: content-type is required for some implementation (JBoss Portal)
075: if (_res.getContentType() == null)
076: _res.setContentType("text/html;charset=UTF-8");
077: return _res.getWriter();
078: }
079:
080: public boolean isCommitted() {
081: return _res.isCommitted();
082: }
083:
084: public void reset() {
085: _res.reset();
086: }
087:
088: public void resetBuffer() {
089: _res.resetBuffer();
090: }
091:
092: public void setBufferSize(int size) {
093: _res.setBufferSize(size);
094: }
095:
096: public void setCharacterEncoding(String charset) {
097: }
098:
099: public void setContentLength(int len) {
100: }
101:
102: public void setContentType(String type) {
103: _res.setContentType(type);
104: }
105:
106: public void setLocale(java.util.Locale loc) {
107: }
108:
109: //-- HttpServletResponse --//
110: public void addCookie(javax.servlet.http.Cookie cookie) {
111: }
112:
113: public void addDateHeader(String name, long date) {
114: }
115:
116: public void addHeader(String name, String value) {
117: }
118:
119: public void addIntHeader(String name, int value) {
120: }
121:
122: public boolean containsHeader(String name) {
123: return false;
124: }
125:
126: /**
127: * @deprecated
128: */
129: public String encodeRedirectUrl(String url) {
130: return encodeRedirectURL(url);
131: }
132:
133: public String encodeRedirectURL(String url) {
134: return encodeURL(url); //try our best
135: }
136:
137: /**
138: * @deprecated
139: */
140: public String encodeUrl(String url) {
141: return encodeURL(url);
142: }
143:
144: public String encodeURL(String url) {
145: return _res.encodeURL(url);
146: }
147:
148: public void sendError(int sc) {
149: }
150:
151: public void sendError(int sc, String msg) {
152: }
153:
154: public void sendRedirect(String location) {
155: }
156:
157: public void setDateHeader(String name, long date) {
158: }
159:
160: public void setHeader(String name, String value) {
161: }
162:
163: public void setIntHeader(String name, int value) {
164: }
165:
166: public void setStatus(int sc) {
167: }
168:
169: /**
170: * @deprecated
171: */
172: public void setStatus(int sc, String sm) {
173: }
174: }
|