KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > maven > cactus > sample > util > FilterServletOutputStream


1 /*
2  * ========================================================================
3  *
4  * Copyright 2001-2003 The Apache Software Foundation.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  * ========================================================================
19  */

20 package org.apache.maven.cactus.sample.util;
21
22 import java.io.DataOutputStream JavaDoc;
23 import java.io.IOException JavaDoc;
24 import java.io.OutputStream JavaDoc;
25
26 import javax.servlet.ServletOutputStream JavaDoc;
27
28 /**
29  * Helper class to help write filters that manipulates the output stream. This
30  * is because normally, the <code>ServletOutputStream</code> cannot be
31  * modified after a resource has committed it.
32  *
33  * Note: This code was adapted from the Filter tutorial found
34  * {@link <a HREF="http://www.orionserver.com/tutorials/filters/lesson3/">
35  * here</a>}
36  *
37  * @version $Id: FilterServletOutputStream.java,v 1.3 2004/02/29 16:34:44 vmassol Exp $
38  *
39  * @see GenericResponseWrapper
40  */

41 public class FilterServletOutputStream extends ServletOutputStream JavaDoc
42 {
43     /**
44      * The stream where all the data will get written to
45      */

46     private DataOutputStream JavaDoc stream;
47
48     /**
49      * Constructor.
50      *
51      * @param theOutput the output stream that we wrap in a
52      * <code>DataOutputStream</code> in order to hold the data
53      */

54     public FilterServletOutputStream(OutputStream JavaDoc theOutput)
55     {
56         stream = new DataOutputStream JavaDoc(theOutput);
57     }
58
59     // Overriden methods from ServletOutputStream ----------------------------
60

61     /**
62      * @see ServletOutputStream#write(int)
63      */

64     public void write(int theByte) throws IOException JavaDoc
65     {
66         stream.write(theByte);
67     }
68
69     /**
70      * @see ServletOutputStream#write(byte[])
71      */

72     public void write(byte[] theBytes) throws IOException JavaDoc
73     {
74         stream.write(theBytes);
75     }
76
77     /**
78      * @see ServletOutputStream#write(byte[], int, int)
79      */

80     public void write(byte[] theByte, int theOffset, int theLength)
81         throws IOException JavaDoc
82     {
83         stream.write(theByte, theOffset, theLength);
84     }
85 }
86
Popular Tags