View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    * 
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   * 
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.apache.commons.io.input;
18  
19  import java.io.FilterReader;
20  import java.io.IOException;
21  import java.io.Reader;
22  
23  /**
24   * A Proxy stream which acts as expected, that is it passes the method 
25   * calls on to the proxied stream and doesn't change which methods are 
26   * being called. 
27   * <p>
28   * It is an alternative base class to FilterReader
29   * to increase reusability, because FilterReader changes the 
30   * methods being called, such as read(char[]) to read(char[], int, int).
31   * 
32   * @author Stephen Colebourne
33   * @version $Id: ProxyReader.java 471628 2006-11-06 04:06:45Z bayard $
34   */
35  public abstract class ProxyReader extends FilterReader {
36  
37      /**
38       * Constructs a new ProxyReader.
39       * 
40       * @param proxy  the Reader to delegate to
41       */
42      public ProxyReader(Reader proxy) {
43          super(proxy);
44          // the proxy is stored in a protected superclass variable named 'in'
45      }
46  
47      /** @see java.io.Reader#read() */
48      public int read() throws IOException {
49          return in.read();
50      }
51  
52      /** @see java.io.Reader#read(char[]) */
53      public int read(char[] chr) throws IOException {
54          return in.read(chr);
55      }
56  
57      /** @see java.io.Reader#read(char[], int, int) */
58      public int read(char[] chr, int st, int end) throws IOException {
59          return in.read(chr, st, end);
60      }
61  
62      /** @see java.io.Reader#skip(long) */
63      public long skip(long ln) throws IOException {
64          return in.skip(ln);
65      }
66  
67      /** @see java.io.Reader#ready() */
68      public boolean ready() throws IOException {
69          return in.ready();
70      }
71  
72      /** @see java.io.Reader#close() */
73      public void close() throws IOException {
74          in.close();
75      }
76  
77      /** @see java.io.Reader#mark(int) */
78      public synchronized void mark(int idx) throws IOException {
79          in.mark(idx);
80      }
81  
82      /** @see java.io.Reader#reset() */
83      public synchronized void reset() throws IOException {
84          in.reset();
85      }
86  
87      /** @see java.io.Reader#markSupported() */
88      public boolean markSupported() {
89          return in.markSupported();
90      }
91  
92  }