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.catalina.ssi;
18:
19: import java.io.ByteArrayOutputStream;
20:
21: import javax.servlet.ServletOutputStream;
22:
23: /**
24: * Class that extends ServletOuputStream, used as a wrapper
25: * from within <code>SsiInclude</code>
26: *
27: * @author Bip Thelin
28: * @version $Revision: 1.3 $, $Date: 2004/02/27 14:58:47 $
29: * @see ServletOutputStream and ByteArrayOutputStream
30: */
31: public class ByteArrayServletOutputStream extends ServletOutputStream {
32: /**
33: * Our buffer to hold the stream
34: */
35: protected ByteArrayOutputStream _buf = null;
36:
37: /**
38: * Construct a new ServletOutputStream
39: *
40: */
41: public ByteArrayServletOutputStream() {
42: _buf = new ByteArrayOutputStream();
43: }
44:
45: /**
46: * Write our stream to the <code>OutputStream</code> provided.
47: *
48: * @param out the OutputStream to write this stream to
49: * @exception IOException if an input/output error occurs
50: */
51: public byte[] toByteArray() {
52: return _buf.toByteArray();
53: }
54:
55: /**
56: * Write to our buffer
57: *
58: * @param b The parameter to write
59: */
60: public void write(int b) {
61: _buf.write(b);
62: }
63: }
|