- java.lang.Object
-
- com.github.jinahya.bit.io.ByteInputAdapter<T>
-
- Type Parameters:
T
- byte source parameter
- All Implemented Interfaces:
ByteInput
,Closeable
,AutoCloseable
- Direct Known Subclasses:
BufferByteInput
,DataByteInput
,StreamByteInput
public abstract class ByteInputAdapter<T> extends Object implements ByteInput
An abstract class implementsByteInput
adapting a specific type of byte source.- Author:
- Jin Kwon <onacit_at_gmail.com>
- See Also:
ByteOutputAdapter
-
-
Constructor Summary
Constructors Constructor Description ByteInputAdapter(Supplier<? extends T> sourceSupplier)
Creates a new instance with specified source supplier.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
close()
Closes this input and releases any system resources associated with it.int
read()
Reads an unsigned 8-bit value.protected abstract int
read(T source)
Reads an 8-bit unsignedint
value from specified source.
-
-
-
Method Detail
-
close
public void close() throws IOException
Closes this input and releases any system resources associated with it.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceByteInput
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
- if an I/O error occurs.
-
read
public int read() throws IOException
Reads an unsigned 8-bit value. Theread()
method ofByteInputAdapter
class invokesread(Object)
with a byte source and returns the result.- Specified by:
read
in interfaceByteInput
- Returns:
- an unsigned 8-bit value; between
0
and255
, both inclusive. - Throws:
IOException
- if an I/O error occurs.
-
read
protected abstract int read(T source) throws IOException
Reads an 8-bit unsignedint
value from specified source.- Parameters:
source
- the source from which an 8-bit unsignedint
value is read.- Returns:
- an 8-bit unsigned
int
value read from thesource
. - Throws:
IOException
- if an I/O error occurs.
-
-