001: /*
002: * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/ResponseWriter.java,v 1.2 2002/03/18 07:15:39 remm Exp $
003: * $Revision: 1.2 $
004: * $Date: 2002/03/18 07:15:39 $
005: *
006: * ====================================================================
007: *
008: * The Apache Software License, Version 1.1
009: *
010: * Copyright (c) 1999 The Apache Software Foundation. All rights
011: * reserved.
012: *
013: * Redistribution and use in source and binary forms, with or without
014: * modification, are permitted provided that the following conditions
015: * are met:
016: *
017: * 1. Redistributions of source code must retain the above copyright
018: * notice, this list of conditions and the following disclaimer.
019: *
020: * 2. Redistributions in binary form must reproduce the above copyright
021: * notice, this list of conditions and the following disclaimer in
022: * the documentation and/or other materials provided with the
023: * distribution.
024: *
025: * 3. The end-user documentation included with the redistribution, if
026: * any, must include the following acknowlegement:
027: * "This product includes software developed by the
028: * Apache Software Foundation (http://www.apache.org/)."
029: * Alternately, this acknowlegement may appear in the software itself,
030: * if and wherever such third-party acknowlegements normally appear.
031: *
032: * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
033: * Foundation" must not be used to endorse or promote products derived
034: * from this software without prior written permission. For written
035: * permission, please contact apache@apache.org.
036: *
037: * 5. Products derived from this software may not be called "Apache"
038: * nor may "Apache" appear in their names without prior written
039: * permission of the Apache Group.
040: *
041: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
042: * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
043: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
044: * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
045: * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
046: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
047: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
048: * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
049: * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
050: * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
051: * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
052: * SUCH DAMAGE.
053: * ====================================================================
054: *
055: * This software consists of voluntary contributions made by many
056: * individuals on behalf of the Apache Software Foundation. For more
057: * information on the Apache Software Foundation, please see
058: * <http://www.apache.org/>.
059: *
060: * [Additional notices, if required by prior licensing conditions]
061: *
062: */
063:
064: package org.apache.catalina.connector;
065:
066: import java.io.IOException;
067: import java.io.OutputStreamWriter;
068: import java.io.PrintWriter;
069:
070: /**
071: * Wrapper around the standard <code>java.io.PrintWriter</code> that keeps
072: * track of whether or not any characters have ever been written (even if they
073: * are still buffered inside the PrintWriter or any other Writer that it uses
074: * above the underlying TCP/IP socket). This is required by the semantics of
075: * several calls on ServletResponse, which are required to throw an
076: * <code>IllegalStateException</code> if output has ever been written.
077: *
078: * @author Craig R. McClanahan
079: * @version $Revision: 1.2 $ $Date: 2002/03/18 07:15:39 $
080: * @deprecated
081: */
082:
083: public class ResponseWriter extends PrintWriter {
084:
085: // ------------------------------------------------------------ Constructor
086:
087: /**
088: * Construct a new ResponseWriter, wrapping the specified writer and
089: * attached to the specified response.
090: *
091: * @param writer OutputStreamWriter to which we are attached
092: * @param stream ResponseStream to which we are attached
093: */
094: public ResponseWriter(OutputStreamWriter writer,
095: ResponseStream stream) {
096:
097: super (writer);
098: this .stream = stream;
099: this .stream.setCommit(false);
100:
101: }
102:
103: // ----------------------------------------------------- Instance Variables
104:
105: /**
106: * The response stream to which we are attached.
107: */
108: protected ResponseStream stream = null;
109:
110: // --------------------------------------------------------- Public Methods
111:
112: /**
113: * Flush this stream, and cause the response to be committed.
114: */
115: public void flush() {
116:
117: stream.setCommit(true);
118: super .flush();
119: stream.setCommit(false);
120:
121: }
122:
123: /**
124: * Print a boolean value.
125: *
126: * @param b The value to be printed
127: */
128: public void print(boolean b) {
129:
130: super .print(b);
131: super .flush();
132:
133: }
134:
135: /**
136: * Print a character value.
137: *
138: * @param c The value to be printed
139: */
140: public void print(char c) {
141:
142: super .print(c);
143: super .flush();
144:
145: }
146:
147: /**
148: * Print a character array value.
149: *
150: * @param ca The value to be printed
151: */
152: public void print(char ca[]) {
153:
154: super .print(ca);
155: super .flush();
156:
157: }
158:
159: /**
160: * Print a double value.
161: *
162: * @param d The value to be printed
163: */
164: public void print(double d) {
165:
166: super .print(d);
167: super .flush();
168:
169: }
170:
171: /**
172: * Print a float value.
173: *
174: * @param f The value to be printed
175: */
176: public void print(float f) {
177:
178: super .print(f);
179: super .flush();
180:
181: }
182:
183: /**
184: * Print an integer value.
185: *
186: * @param i The value to be printed.
187: */
188: public void print(int i) {
189:
190: super .print(i);
191: super .flush();
192:
193: }
194:
195: /**
196: * Print a long value.
197: *
198: * @param l The value to be printed
199: */
200: public void print(long l) {
201:
202: super .print(l);
203: super .flush();
204:
205: }
206:
207: /**
208: * Print an object value.
209: *
210: * @param o The value to be printed
211: */
212: public void print(Object o) {
213:
214: super .print(o);
215: super .flush();
216:
217: }
218:
219: /**
220: * Print a String value.
221: *
222: * @param s The value to be printed
223: */
224: public void print(String s) {
225:
226: super .print(s);
227: super .flush();
228:
229: }
230:
231: /**
232: * Terminate the current line by writing the line separator string.
233: */
234: public void println() {
235:
236: super .println();
237: super .flush();
238:
239: }
240:
241: /**
242: * Print a boolean value and terminate the current line.
243: *
244: * @param b The value to be printed
245: */
246: public void println(boolean b) {
247:
248: super .println(b);
249: super .flush();
250:
251: }
252:
253: /**
254: * Print a character value and terminate the current line.
255: *
256: * @param c The value to be printed
257: */
258: public void println(char c) {
259:
260: super .println(c);
261: super .flush();
262:
263: }
264:
265: /**
266: * Print a character array value and terminate the current line.
267: *
268: * @param ca The value to be printed
269: */
270: public void println(char ca[]) {
271:
272: super .println(ca);
273: super .flush();
274:
275: }
276:
277: /**
278: * Print a double value and terminate the current line.
279: *
280: * @param d The value to be printed
281: */
282: public void println(double d) {
283:
284: super .println(d);
285: super .flush();
286:
287: }
288:
289: /**
290: * Print a float value and terminate the current line.
291: *
292: * @param f The value to be printed
293: */
294: public void println(float f) {
295:
296: super .println(f);
297: super .flush();
298:
299: }
300:
301: /**
302: * Print an integer value and terminate the current line.
303: *
304: * @param i The value to be printed.
305: */
306: public void println(int i) {
307:
308: super .println(i);
309: super .flush();
310:
311: }
312:
313: /**
314: * Print a long value and terminate the current line.
315: *
316: * @param l The value to be printed
317: */
318: public void println(long l) {
319:
320: super .println(l);
321: super .flush();
322:
323: }
324:
325: /**
326: * Print an object value and terminate the current line.
327: *
328: * @param o The value to be printed
329: */
330: public void println(Object o) {
331:
332: super .println(o);
333: super .flush();
334:
335: }
336:
337: /**
338: * Print a String value and terminate the current line.
339: *
340: * @param s The value to be printed
341: */
342: public void println(String s) {
343:
344: super .println(s);
345: super .flush();
346:
347: }
348:
349: /**
350: * Write a single character.
351: *
352: * @param c The value to be written
353: */
354: public void write(char c) {
355:
356: super .write(c);
357: super .flush();
358:
359: }
360:
361: /**
362: * Write an array of characters.
363: *
364: * @param ca The value to be written
365: */
366: public void write(char ca[]) {
367:
368: super .write(ca);
369: super .flush();
370:
371: }
372:
373: /**
374: * Write a portion of an array of characters.
375: *
376: * @param ca The array from which to write
377: * @param off Starting offset
378: * @param len Number of characters to write
379: */
380: public void write(char ca[], int off, int len) {
381:
382: super .write(ca, off, len);
383: super .flush();
384:
385: }
386:
387: /**
388: * Write a String.
389: *
390: * @param s The value to be written
391: */
392: public void write(String s) {
393:
394: super .write(s);
395: super .flush();
396:
397: }
398:
399: /**
400: * Write a portion of a String.
401: *
402: * @param s The String from which to write
403: * @param off Starting offset
404: * @param len Number of characters to write
405: */
406: public void write(String s, int off, int len) {
407:
408: super.write(s, off, len);
409: super.flush();
410:
411: }
412:
413: }
|