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