001 package org.shiftone.jrat.util.io.proxy;
002
003
004 import org.shiftone.jrat.core.JRatException;
005 import org.shiftone.jrat.util.log.Logger;
006
007 import java.io.IOException;
008 import java.io.InputStream;
009
010
011 /**
012 * @author jeff@shiftone.org (Jeff Drost)
013 */
014 public abstract class ProxyInputStream extends InputStream {
015
016 private static final Logger LOG = Logger.getLogger(ProxyInputStream.class);
017
018 protected abstract InputStream getTarget() throws IOException;
019
020
021 private InputStream getTargetRTE() {
022
023 try {
024 return getTarget();
025 }
026 catch (IOException e) {
027 throw new JRatException("failed to get target InputStream", e);
028 }
029 }
030
031
032 public int read() throws IOException {
033 return getTarget().read();
034 }
035
036
037 public int read(byte[] b) throws IOException {
038 return getTarget().read(b);
039 }
040
041
042 public int read(byte[] b, int off, int len) throws IOException {
043 return getTarget().read(b, off, len);
044 }
045
046
047 public long skip(long n) throws IOException {
048 return getTarget().skip(n);
049 }
050
051
052 public int available() throws IOException {
053 return getTarget().available();
054 }
055
056
057 public void close() throws IOException {
058 getTarget().close();
059 }
060
061
062 public void mark(int readlimit) {
063 getTargetRTE().mark(readlimit);
064 }
065
066
067 public void reset() throws IOException {
068 getTarget().reset();
069 }
070
071
072 public boolean markSupported() {
073 return getTargetRTE().markSupported();
074 }
075 }