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.tomcat4;
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: final 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: // --------------------------------------------------- OutputStream Methods
42:
43: public void write(int i) throws IOException {
44: ob.writeByte(i);
45: }
46:
47: public void write(byte[] b) throws IOException {
48: write(b, 0, b.length);
49: }
50:
51: public void write(byte[] b, int off, int len) throws IOException {
52: ob.write(b, off, len);
53: }
54:
55: /**
56: * Will send the buffer to the client.
57: */
58: public void flush() throws IOException {
59: ob.flush();
60: }
61:
62: public void close() throws IOException {
63: ob.close();
64: }
65:
66: // -------------------------------------------- ServletOutputStream Methods
67:
68: public void print(String s) throws IOException {
69: ob.write(s);
70: }
71:
72: }
|