KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * Copyright 2002-2006 the original author or authors.
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.InputStream JavaDoc;
21
22 import javax.servlet.ServletInputStream JavaDoc;
23
24 /**
25  * Delegating implementation of ServletInputStream.
26  * @author Joe Walker [joe at getahead dot ltd dot uk]
27  */

28 public class DelegatingServletInputStream extends ServletInputStream JavaDoc
29 {
30     /**
31      * Create a new DelegatingServletInputStream.
32      * @param proxy the sourceStream InputStream
33      */

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

43     public InputStream JavaDoc getTargetStream()
44     {
45         return proxy;
46     }
47
48     /**
49      * @return The stream that we proxy to
50      */

51     public InputStream JavaDoc getSourceStream()
52     {
53         return proxy;
54     }
55
56     /* (non-Javadoc)
57      * @see java.io.InputStream#read()
58      */

59     public int read() throws IOException JavaDoc
60     {
61         return proxy.read();
62     }
63
64     /* (non-Javadoc)
65      * @see java.io.InputStream#close()
66      */

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