KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > catalina > connector > CoyoteOutputStream


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * 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
19 package org.apache.catalina.connector;
20
21 import java.io.IOException JavaDoc;
22
23 import javax.servlet.ServletOutputStream JavaDoc;
24
25 /**
26  * Coyote implementation of the servlet output stream.
27  *
28  * @author Costin Manolache
29  * @author Remy Maucherat
30  */

31 public class CoyoteOutputStream
32     extends ServletOutputStream JavaDoc {
33
34
35     // ----------------------------------------------------- Instance Variables
36

37
38     protected OutputBuffer ob;
39
40
41     // ----------------------------------------------------------- Constructors
42

43
44     protected CoyoteOutputStream(OutputBuffer ob) {
45         this.ob = ob;
46     }
47
48
49     // --------------------------------------------------------- Public Methods
50

51
52     /**
53      * Prevent cloning the facade.
54      */

55     protected Object JavaDoc clone()
56         throws CloneNotSupportedException JavaDoc {
57         throw new CloneNotSupportedException JavaDoc();
58     }
59
60
61     // -------------------------------------------------------- Package Methods
62

63
64     /**
65      * Clear facade.
66      */

67     void clear() {
68         ob = null;
69     }
70
71
72     // --------------------------------------------------- OutputStream Methods
73

74
75     public void write(int i)
76         throws IOException JavaDoc {
77         ob.writeByte(i);
78     }
79
80
81     public void write(byte[] b)
82         throws IOException JavaDoc {
83         write(b, 0, b.length);
84     }
85
86
87     public void write(byte[] b, int off, int len)
88         throws IOException JavaDoc {
89         ob.write(b, off, len);
90     }
91
92
93     /**
94      * Will send the buffer to the client.
95      */

96     public void flush()
97         throws IOException JavaDoc {
98         ob.flush();
99     }
100
101
102     public void close()
103         throws IOException JavaDoc {
104         ob.close();
105     }
106
107
108     // -------------------------------------------- ServletOutputStream Methods
109

110
111     public void print(String JavaDoc s)
112         throws IOException JavaDoc {
113         ob.write(s);
114     }
115
116
117 }
118
119
Popular Tags