001: /**
002: * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
003: *
004: * Permission is hereby granted, free of charge, to any person obtaining a copy
005: * of this software and associated documentation files (the "Software"), to deal
006: * in the Software without restriction, including without limitation the rights
007: * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
008: * copies of the Software, and to permit persons to whom the Software is
009: * furnished to do so, subject to the following conditions:
010: *
011: * The above copyright notice and this permission notice shall be included in
012: * all copies or substantial portions of the Software.
013: *
014: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
015: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
016: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
017: * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
018: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
019: * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
020: * SOFTWARE.
021: */package com.liferay.portal.wsrp;
022:
023: import com.liferay.portal.kernel.util.ByteArrayMaker;
024:
025: import java.io.IOException;
026: import java.io.PrintWriter;
027: import java.io.Serializable;
028: import java.io.StringWriter;
029: import java.io.UnsupportedEncodingException;
030:
031: import java.util.Locale;
032:
033: import javax.servlet.ServletOutputStream;
034: import javax.servlet.http.Cookie;
035: import javax.servlet.http.HttpServletResponse;
036:
037: /**
038: * <a href="WSRPServletResponse.java.html"><b><i>View Source</i></b></a>
039: *
040: * @author Michael Young
041: *
042: */
043: public class WSRPServletResponse implements HttpServletResponse,
044: Serializable {
045:
046: public static final int DEFAULT_STATUS_CODE = 200;
047:
048: public WSRPServletResponse() {
049: _locale = new Locale("en", "US");
050:
051: setContentType("text/html");
052: }
053:
054: public void setBufferSize(int size) {
055: }
056:
057: public int getBufferSize() {
058: return 4096;
059: }
060:
061: public void setCharacterEncoding(String encoding) {
062: _encoding = encoding;
063: }
064:
065: public String getCharacterEncoding() {
066: return _encoding;
067: }
068:
069: public boolean isCommitted() {
070: return false;
071: }
072:
073: public void setContentLength(int size) {
074: }
075:
076: public void setContentType(String contentType) {
077: _contentType = contentType;
078: }
079:
080: public String getContentType() {
081: return _contentType;
082: }
083:
084: public void setDateHeader(String name, long dateValue) {
085: }
086:
087: public void setHeader(String name, String value) {
088: }
089:
090: public void setIntHeader(String name, int value) {
091: }
092:
093: public void setLocale(Locale locale) {
094: _locale = locale;
095: }
096:
097: public java.util.Locale getLocale() {
098: return _locale;
099: }
100:
101: public ServletOutputStream getOutputStream() {
102: _callGetOutputStream = true;
103:
104: return _sos;
105: }
106:
107: public void setStatus(int statusCode) {
108: }
109:
110: public void setStatus(int statusCode, String message) {
111: }
112:
113: public String getString() throws UnsupportedEncodingException {
114: if (_callGetOutputStream) {
115: return _bam.toString();
116: } else if (_callGetWriter) {
117: return _sw.toString();
118: } else {
119: return "";
120: }
121: }
122:
123: public PrintWriter getWriter() {
124: _callGetWriter = true;
125:
126: return _pw;
127: }
128:
129: public void addCookie(Cookie cookie) {
130: }
131:
132: public void addDateHeader(String name, long dateValue) {
133: }
134:
135: public void addHeader(String name, String value) {
136: }
137:
138: public void addIntHeader(String name, int value) {
139: }
140:
141: public boolean containsHeader(String headerName) {
142: return false;
143: }
144:
145: public String encodeRedirectURL(String url) {
146: return url;
147: }
148:
149: public String encodeRedirectUrl(String url) {
150: return encodeRedirectURL(url);
151: }
152:
153: public String encodeURL(String url) {
154: return url;
155: }
156:
157: public String encodeUrl(String url) {
158: return encodeURL(url);
159: }
160:
161: public void flushBuffer() {
162: }
163:
164: public void reset() {
165: }
166:
167: public void resetBuffer() {
168: }
169:
170: public void sendError(int errorCode) throws IOException {
171: }
172:
173: public void sendError(int errorCode, String message)
174: throws IOException {
175: }
176:
177: public void sendRedirect(String location) {
178: }
179:
180: private ByteArrayMaker _bam = new ByteArrayMaker();
181: private Locale _locale;
182: private ServletOutputStream _sos = new ServletOutputStream() {
183: public void write(int b) throws IOException {
184: _bam.write(b);
185: }
186: };
187:
188: private String _encoding;
189: private StringWriter _sw = new StringWriter();
190: private PrintWriter _pw = new PrintWriter(_sw);
191: private boolean _callGetOutputStream;
192: private boolean _callGetWriter;
193: private String _contentType;
194:
195: }
|