KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > io > input > ProxyInputStream


1 /*
2  * Copyright 2002-2004 The Apache Software Foundation.
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 package org.apache.commons.io.input;
17
18 import java.io.FilterInputStream JavaDoc;
19 import java.io.IOException JavaDoc;
20 import java.io.InputStream JavaDoc;
21
22 /**
23  * A Proxy stream which acts as expected, that is it passes the method
24  * calls on to the proxied stream and doesn't change which methods are
25  * being called.
26  *
27  * It is an alternative base class to FilterInputStream
28  * to increase reusability, because FilterInputStream changes the
29  * methods being called, such as read(byte[]) to read(byte[], int, int).
30  */

31 public abstract class ProxyInputStream extends FilterInputStream JavaDoc {
32
33     private InputStream JavaDoc proxy;
34
35     /**
36      * Constructs a new ProxyInputStream.
37      * @param proxy InputStream to delegate to
38      */

39     public ProxyInputStream(InputStream JavaDoc proxy) {
40         super(proxy);
41         this.proxy = proxy;
42     }
43
44     /** @see java.io.InputStream#read() */
45     public int read() throws IOException JavaDoc {
46         return this.proxy.read();
47     }
48
49     /** @see java.io.InputStream#read(byte[]) */
50     public int read(byte[] bts) throws IOException JavaDoc {
51         return this.proxy.read(bts);
52     }
53
54     /** @see java.io.InputStream#read(byte[], int, int) */
55     public int read(byte[] bts, int st, int end) throws IOException JavaDoc {
56         return this.proxy.read(bts, st, end);
57     }
58
59     /** @see java.io.InputStream#skip(long) */
60     public long skip(long ln) throws IOException JavaDoc {
61         return this.proxy.skip(ln);
62     }
63
64     /** @see java.io.InputStream#available() */
65     public int available() throws IOException JavaDoc {
66         return this.proxy.available();
67     }
68
69     /** @see java.io.InputStream#close() */
70     public void close() throws IOException JavaDoc {
71         this.proxy.close();
72     }
73
74     /** @see java.io.InputStream#mark(int) */
75     public synchronized void mark(int idx) {
76         this.proxy.mark(idx);
77     }
78
79     /** @see java.io.InputStream#reset() */
80     public synchronized void reset() throws IOException JavaDoc {
81         this.proxy.reset();
82     }
83
84     /** @see java.io.InputStream#markSupported() */
85     public boolean markSupported() {
86         return this.proxy.markSupported();
87     }
88
89 }
90
Popular Tags