001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package org.apache.cocoon.components.jsp;
018:
019: import java.io.IOException;
020: import java.io.PrintWriter;
021: import java.util.Locale;
022:
023: import javax.servlet.ServletOutputStream;
024: import javax.servlet.http.Cookie;
025: import javax.servlet.http.HttpServletResponse;
026:
027: /**
028: * Stub implementation of HttpServletResponse.
029: */
030: public class JSPEngineServletResponse implements HttpServletResponse {
031:
032: private final HttpServletResponse servletResponse;
033: private final JSPEngineServletOutputStream output;
034:
035: private boolean hasWriter = false;
036: private boolean hasOutputStream = false;
037:
038: public JSPEngineServletResponse(
039: HttpServletResponse servletResponse,
040: JSPEngineServletOutputStream output) {
041: this .servletResponse = servletResponse;
042: this .output = output;
043: }
044:
045: public String getCharacterEncoding() {
046: return this .servletResponse.getCharacterEncoding();
047: }
048:
049: public Locale getLocale() {
050: return this .servletResponse.getLocale();
051: }
052:
053: public PrintWriter getWriter() {
054: if (this .hasOutputStream) {
055: throw new IllegalStateException(
056: "getOutputStream was already called.");
057: }
058: this .hasWriter = true;
059: return this .output.getWriter();
060: }
061:
062: public void setContentLength(int len) {
063: // this value can be overriden by cocoon
064: servletResponse.setContentLength(len);
065: }
066:
067: public void setContentType(java.lang.String type) {
068: servletResponse.setContentType(type);
069: }
070:
071: public void setLocale(java.util.Locale loc) {
072: servletResponse.setLocale(loc);
073: }
074:
075: public ServletOutputStream getOutputStream() {
076: if (this .hasWriter) {
077: throw new IllegalStateException(
078: "getWriter was already called.");
079: }
080: this .hasOutputStream = true;
081: return this .output;
082: }
083:
084: public void addCookie(Cookie cookie) {
085: servletResponse.addCookie(cookie);
086: }
087:
088: public boolean containsHeader(String s) {
089: return servletResponse.containsHeader(s);
090: }
091:
092: /** @deprecated use encodeURL(String url) instead. */
093: public String encodeUrl(String s) {
094: return servletResponse.encodeUrl(s);
095: }
096:
097: public String encodeURL(String s) {
098: return servletResponse.encodeURL(s);
099: }
100:
101: /** @deprecated use encodeRedirectURL(String url) instead. */
102: public String encodeRedirectUrl(String s) {
103: return servletResponse.encodeRedirectUrl(s);
104: }
105:
106: public String encodeRedirectURL(String s) {
107: return servletResponse.encodeRedirectURL(s);
108: }
109:
110: public void sendError(int i, String s) throws IOException {
111: servletResponse.sendError(i, s);
112: }
113:
114: public void sendError(int i) throws IOException {
115: servletResponse.sendError(i);
116: }
117:
118: public void sendRedirect(String s) throws IOException {
119: servletResponse.sendRedirect(s);
120: }
121:
122: public void setDateHeader(String s, long l) {
123: servletResponse.setDateHeader(s, l);
124: }
125:
126: public void addDateHeader(String s, long l) {
127: servletResponse.addDateHeader(s, l);
128: }
129:
130: public void setHeader(String s, String s1) {
131: servletResponse.setHeader(s, s1);
132: }
133:
134: public void addHeader(String s, String s1) {
135: servletResponse.addHeader(s, s1);
136: }
137:
138: public void setIntHeader(String s, int i) {
139: servletResponse.setIntHeader(s, i);
140: }
141:
142: public void addIntHeader(String s, int i) {
143: servletResponse.addIntHeader(s, i);
144: }
145:
146: public void setStatus(int i) {
147: servletResponse.setStatus(i);
148: }
149:
150: /** @deprecated use sendError(int, String) instead */
151: public void setStatus(int i, String s) {
152: servletResponse.setStatus(i, s);
153: }
154:
155: public void resetBuffer() {
156: }
157:
158: public void reset() {
159: }
160:
161: public int getBufferSize() {
162: return 1024;
163: }
164:
165: public void setBufferSize(int size) {
166: }
167:
168: public void flushBuffer() throws IOException {
169: }
170:
171: public boolean isCommitted() {
172: return false;
173: }
174:
175: }
|