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. import java.io.FilterReader;
  18. import java.io.IOException;
  19. import java.io.Reader;
  20. /**
  21. * A Proxy stream which acts as expected, that is it passes the method
  22. * calls on to the proxied stream and doesn't change which methods are
  23. * being called.
  24. *
  25. * It is an alternative base class to FilterReader
  26. * to increase reusability, because FilterReader changes the
  27. * methods being called, such as read(char[]) to read(char[], int, int).
  28. */
  29. public abstract class ProxyReader extends FilterReader {
  30. private Reader proxy;
  31. /**
  32. * Constructs a new ProxyReader.
  33. * @param proxy Reader to delegate to
  34. */
  35. public ProxyReader(Reader proxy) {
  36. super(proxy);
  37. this.proxy = proxy;
  38. }
  39. /** @see java.io.Reader#read() */
  40. public int read() throws IOException {
  41. return this.proxy.read();
  42. }
  43. /** @see java.io.Reader#read(char[]) */
  44. public int read(char[] chr) throws IOException {
  45. return this.proxy.read(chr);
  46. }
  47. /** @see java.io.Reader#read(char[], int, int) */
  48. public int read(char[] chr, int st, int end) throws IOException {
  49. return this.proxy.read(chr, st, end);
  50. }
  51. /** @see java.io.Reader#skip(long) */
  52. public long skip(long ln) throws IOException {
  53. return this.proxy.skip(ln);
  54. }
  55. /** @see java.io.Reader#ready() */
  56. public boolean ready() throws IOException {
  57. return this.proxy.ready();
  58. }
  59. /** @see java.io.Reader#close() */
  60. public void close() throws IOException {
  61. this.proxy.close();
  62. }
  63. /** @see java.io.Reader#mark(int) */
  64. public synchronized void mark(int idx) throws IOException {
  65. this.proxy.mark(idx);
  66. }
  67. /** @see java.io.Reader#reset() */
  68. public synchronized void reset() throws IOException {
  69. this.proxy.reset();
  70. }
  71. /** @see java.io.Reader#markSupported() */
  72. public boolean markSupported() {
  73. return this.proxy.markSupported();
  74. }
  75. }