/* * Copyright (c) 2012 Data Harmonisation Panel * * All rights reserved. This program and the accompanying materials are made * available under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation, either version 3 of the License, * or (at your option) any later version. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution. If not, see <http://www.gnu.org/licenses/>. * * Contributors: * HUMBOLDT EU Integrated Project #030962 * Data Harmonisation Panel <http://www.dhpanel.eu> */ package eu.esdihumboldt.util.io; import java.io.FilterInputStream; import java.io.IOException; import java.io.InputStream; /** * Decorator on an {@link InputStream}. Alternative to {@link FilterInputStream} * that calls the same methods on the decoratee that were actually called. * * @author Simon Templer */ public class InputStreamDecorator extends InputStream { private final InputStream in; /** * Creates a decorator for the given input stream * * @param in the input stream to decorate */ public InputStreamDecorator(InputStream in) { super(); this.in = in; } /** * @see java.io.InputStream#available() */ @Override public int available() throws IOException { return in.available(); } /** * @see java.io.InputStream#close() */ @Override public void close() throws IOException { in.close(); } /** * @see java.io.InputStream#mark(int) */ @Override public void mark(int readLimit) { in.mark(readLimit); } /** * @see java.io.InputStream#markSupported() */ @Override public boolean markSupported() { return in.markSupported(); } /** * @see java.io.InputStream#read() */ @Override public int read() throws IOException { return in.read(); } /** * @see java.io.InputStream#read(byte[], int, int) */ @Override public int read(byte[] b, int off, int len) throws IOException { return in.read(b, off, len); } /** * @see java.io.InputStream#read(byte[]) */ @Override public int read(byte[] b) throws IOException { return in.read(b); } /** * @see java.io.InputStream#reset() */ @Override public void reset() throws IOException { in.reset(); } /** * @see java.io.InputStream#skip(long) */ @Override public long skip(long n) throws IOException { return in.skip(n); } /** * @see java.lang.Object#toString() */ @Override public String toString() { return in.toString(); } }