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.FilterInputStream; 20 import java.io.IOException; 21 import java.io.InputStream; 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 FilterInputStream 29 * to increase reusability, because FilterInputStream changes the 30 * methods being called, such as read(byte[]) to read(byte[], int, int). 31 * 32 * @author Stephen Colebourne 33 * @version $Id: ProxyInputStream.java 471628 2006-11-06 04:06:45Z bayard $ 34 */ 35 public abstract class ProxyInputStream extends FilterInputStream { 36 37 /** 38 * Constructs a new ProxyInputStream. 39 * 40 * @param proxy the InputStream to delegate to 41 */ 42 public ProxyInputStream(InputStream proxy) { 43 super(proxy); 44 // the proxy is stored in a protected superclass variable named 'in' 45 } 46 47 /** @see java.io.InputStream#read() */ 48 public int read() throws IOException { 49 return in.read(); 50 } 51 52 /** @see java.io.InputStream#read(byte[]) */ 53 public int read(byte[] bts) throws IOException { 54 return in.read(bts); 55 } 56 57 /** @see java.io.InputStream#read(byte[], int, int) */ 58 public int read(byte[] bts, int st, int end) throws IOException { 59 return in.read(bts, st, end); 60 } 61 62 /** @see java.io.InputStream#skip(long) */ 63 public long skip(long ln) throws IOException { 64 return in.skip(ln); 65 } 66 67 /** @see java.io.InputStream#available() */ 68 public int available() throws IOException { 69 return in.available(); 70 } 71 72 /** @see java.io.InputStream#close() */ 73 public void close() throws IOException { 74 in.close(); 75 } 76 77 /** @see java.io.InputStream#mark(int) */ 78 public synchronized void mark(int idx) { 79 in.mark(idx); 80 } 81 82 /** @see java.io.InputStream#reset() */ 83 public synchronized void reset() throws IOException { 84 in.reset(); 85 } 86 87 /** @see java.io.InputStream#markSupported() */ 88 public boolean markSupported() { 89 return in.markSupported(); 90 } 91 92 }