01: /*
02: * Copyright 1999,2004 The Apache Software Foundation.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.apache.coyote.tomcat5;
18:
19: import java.io.IOException;
20:
21: import javax.servlet.ServletOutputStream;
22:
23: /**
24: * Coyote implementation of the servlet output stream.
25: *
26: * @author Costin Manolache
27: * @author Remy Maucherat
28: */
29: public class CoyoteOutputStream extends ServletOutputStream {
30:
31: // ----------------------------------------------------- Instance Variables
32:
33: protected OutputBuffer ob;
34:
35: // ----------------------------------------------------------- Constructors
36:
37: protected CoyoteOutputStream(OutputBuffer ob) {
38: this .ob = ob;
39: }
40:
41: // -------------------------------------------------------- Package Methods
42:
43: /**
44: * Clear facade.
45: */
46: void clear() {
47: ob = null;
48: }
49:
50: // --------------------------------------------------- OutputStream Methods
51:
52: public void write(int i) throws IOException {
53: ob.writeByte(i);
54: }
55:
56: public void write(byte[] b) throws IOException {
57: write(b, 0, b.length);
58: }
59:
60: public void write(byte[] b, int off, int len) throws IOException {
61: ob.write(b, off, len);
62: }
63:
64: /**
65: * Will send the buffer to the client.
66: */
67: public void flush() throws IOException {
68: ob.flush();
69: }
70:
71: public void close() throws IOException {
72: ob.close();
73: }
74:
75: // -------------------------------------------- ServletOutputStream Methods
76:
77: public void print(String s) throws IOException {
78: ob.write(s);
79: }
80:
81: }
|