KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > directwebremoting > util > DelegatingServletOutputStream


1 /*
2  * Copyright 2005 Joe Walker
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.directwebremoting.util;
18
19 import java.io.IOException JavaDoc;
20 import java.io.OutputStream JavaDoc;
21
22 import javax.servlet.ServletOutputStream JavaDoc;
23
24 /**
25  * Delegating implementation of ServletOutputStream.
26  */

27 public class DelegatingServletOutputStream extends ServletOutputStream JavaDoc
28 {
29     /**
30      * Create a new DelegatingServletOutputStream.
31      * @param targetStream the target OutputStream
32      */

33     public DelegatingServletOutputStream(OutputStream JavaDoc targetStream)
34     {
35         this.proxy = targetStream;
36     }
37
38     /**
39      * Accessor for the stream that we are proxying to
40      * @return The stream we proxy to
41      */

42     public OutputStream JavaDoc getTargetStream()
43     {
44         return proxy;
45     }
46
47     /* (non-Javadoc)
48      * @see java.io.OutputStream#write(int)
49      */

50     public void write(int b) throws IOException JavaDoc
51     {
52         proxy.write(b);
53     }
54
55     /* (non-Javadoc)
56      * @see java.io.OutputStream#flush()
57      */

58     public void flush() throws IOException JavaDoc
59     {
60         super.flush();
61         proxy.flush();
62     }
63
64     /* (non-Javadoc)
65      * @see java.io.OutputStream#close()
66      */

67     public void close() throws IOException JavaDoc
68     {
69         super.close();
70         proxy.close();
71     }
72
73     private final OutputStream JavaDoc proxy;
74 }
75
Popular Tags