- java.lang.Object
-
- com.github.jinahya.bit.io.BitInputAdapter
-
- All Implemented Interfaces:
BitInput
,Closeable
,AutoCloseable
public class BitInputAdapter extends Object implements BitInput
- Author:
- Jin Kwon <onacit_at_gmail.com>
- See Also:
BitOutputAdapter
-
-
Constructor Summary
Constructors Constructor Description BitInputAdapter(Supplier<? extends ByteInput> inputSupplier)
Creates a new instance with specified input supplier.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long
align(int bytes)
Aligns to specified number of bytes by discarding bits.void
close()
Closes this input and releases any system resources associated with it.int
readInt(boolean unsigned, int size)
Reads anint
value of specified number of bits.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.github.jinahya.bit.io.BitInput
align, readBoolean, readByte, readByte, readByte8, readChar, readChar16, readDouble64, readFloat32, readInt, readInt32, readInt32Le, readLong, readLong, readLong64, readLong64Le, readShort, readShort, readShort16, readShort16Le, readUnsignedByte, readUnsignedInt, readUnsignedLong, readUnsignedShort, readValue, skip
-
-
-
-
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 interfaceBitInput
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
- if an I/O error occurs.- See Also:
ByteInput.close()
-
readInt
public int readInt(boolean unsigned, int size) throws IOException
Description copied from interface:BitInput
Reads anint
value of specified number of bits.- Specified by:
readInt
in interfaceBitInput
- Parameters:
unsigned
- a flag for indicating unsigned value;true
for unsigned,false
for signed.size
- the number of bits to read; between1
and (32 - (unsigned ? 1: 0
)), both inclusive.- Returns:
- an
int
value of specifiedsize
. - Throws:
IOException
- if an I/O error occurs.
-
align
public long align(int bytes) throws IOException
Description copied from interface:BitInput
Aligns to specified number of bytes by discarding bits.- Specified by:
align
in interfaceBitInput
- Parameters:
bytes
- the number of bytes to align; must be positive.- Returns:
- the number of bits discarded while aligning.
- Throws:
IOException
- if an I/O error occurs.
-
-