- java.lang.Object
-
- java.io.InputStream
-
- org.refcodes.io.InverseInputStream
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
public class InverseInputStream extends InputStream
AInverseInputStream
wraps anInputStream
and consumes input bytes by applying aInverseFunction
on each byte read from the providedInputStream
before passing back the processed byte to the caller. The input of theInverseInputStream
can be converted back by the accordingBijectiveOutputStream
.
-
-
Constructor Summary
Constructors Constructor Description InverseInputStream(InputStream aInputStream, org.refcodes.numerical.InverseFunction<Byte,Byte> aInverseFunction)
Constructs theInverseInputStream
by wrapping the givenInputStream
for the providedInverseFunction
to be applied on the bytes to be read.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
available()
void
close()
boolean
equals(Object aObj)
int
hashCode()
void
mark(int aReadlimit)
boolean
markSupported()
int
read()
void
reset()
long
skip(long aArg0)
String
toString()
-
Methods inherited from class java.io.InputStream
nullInputStream, read, read, readAllBytes, readNBytes, readNBytes, transferTo
-
-
-
-
Constructor Detail
-
InverseInputStream
public InverseInputStream(InputStream aInputStream, org.refcodes.numerical.InverseFunction<Byte,Byte> aInverseFunction)
Constructs theInverseInputStream
by wrapping the givenInputStream
for the providedInverseFunction
to be applied on the bytes to be read.- Parameters:
aInputStream
- TheInputStream
to be wrapped.aInverseFunction
- TheInverseFunction
to be applied to the bytes to be read.
-
-
Method Detail
-
available
public int available() throws IOException
- Overrides:
available
in classInputStream
- Throws:
IOException
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classInputStream
- Throws:
IOException
-
mark
public void mark(int aReadlimit)
- Overrides:
mark
in classInputStream
-
markSupported
public boolean markSupported()
- Overrides:
markSupported
in classInputStream
-
read
public int read() throws IOException
- Specified by:
read
in classInputStream
- Throws:
IOException
-
reset
public void reset() throws IOException
- Overrides:
reset
in classInputStream
- Throws:
IOException
-
skip
public long skip(long aArg0) throws IOException
- Overrides:
skip
in classInputStream
- Throws:
IOException
-
-