Class ByteInputAdapter

java.lang.Object
com.github.jinahya.bit.io.ByteInputAdapter
All Implemented Interfaces:
BitInput

public class ByteInputAdapter extends Object implements BitInput
An implementation of BitInput reads octets from an instance of ByteInput.
Author:
Jin Kwon <onacit_at_gmail.com>
See Also:
  • Constructor Details

    • ByteInputAdapter

      public ByteInputAdapter(ByteInput input)
      Creates a new instance on top of specified byte input.
      Parameters:
      input - the byte input.
  • Method Details

    • readInt

      public int readInt(boolean unsigned, int size) throws IOException
      Description copied from interface: BitInput
      Reads an int value of specified number of bits.
      Specified by:
      readInt in interface BitInput
      Parameters:
      unsigned - a flag for indicating unsigned value; true for unsigned, false for signed.
      size - the number of bits to read; between 1 and (32 - (unsigned ? 1: 0)), both inclusive.
      Returns:
      an int value of size bits.
      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 reading (and discarding) required number of bits.
      Specified by:
      align in interface BitInput
      Parameters:
      bytes - the number of bytes to align; must be positive.
      Returns:
      the number of bits discarded; non-negative, always.
      Throws:
      IOException - if an I/O error occurs.
    • reset

      public void reset()
      Description copied from interface: BitInput
      Resets the total number of bytes read so far to 0.
      Specified by:
      reset in interface BitInput