Class SingleBlockBitmap

java.lang.Object
io.bytestreams.codec.iso8583.SingleBlockBitmap
All Implemented Interfaces:
Bitmap

public class SingleBlockBitmap extends Object implements Bitmap
SingleBlockBitmap is a Bitmap backed by a BitSet. It has a fixed capacity and cannot be extended.
  • Constructor Details

    • SingleBlockBitmap

      public SingleBlockBitmap(int size)
      Creates a new SingleBlockBitmap.
      Parameters:
      size - the number of bytes in the block.
  • Method Details

    • valueOf

      public static SingleBlockBitmap valueOf(byte[] bytes)
      Creates a new SingleBlockBitmap.
      Parameters:
      bytes - the byte array representation of the bitmap.
      Returns:
      the SingleBlockBitmap.
    • capacity

      public int capacity()
      Description copied from interface: Bitmap
      Returns the total number of bits in the bitmap.
      Specified by:
      capacity in interface Bitmap
      Returns:
      the total number of bits in the Bitmap.
    • get

      public boolean get(int bit)
      Checks if the given bit is set.
      Specified by:
      get in interface Bitmap
      Parameters:
      bit - the bit to check. NOTE: The bit index starts from 1.
      Returns:
      true if the bit is set, false otherwise.
    • set

      public boolean set(int bit)
      Sets the given bit.
      Specified by:
      set in interface Bitmap
      Parameters:
      bit - the bit to set. NOTE: The bit index starts from 1.
      Returns:
      true if the bit was not already set, false otherwise.
    • clear

      public boolean clear(int bit)
      Clears the given bit.
      Specified by:
      clear in interface Bitmap
      Parameters:
      bit - the bit to clear. NOTE: The bit index starts from 1.
      Returns:
      true if the bit was set, false otherwise.
    • cardinality

      public int cardinality()
      Description copied from interface: Bitmap
      Returns the number of bits that are set.
      Specified by:
      cardinality in interface Bitmap
      Returns:
      the number of bits set in the Bitmap.
    • stream

      public IntStream stream()
      Description copied from interface: Bitmap
      Returns a stream of the 1-based indices of all set bits.
      Specified by:
      stream in interface Bitmap
      Returns:
      a stream of the bits set in the Bitmap.
    • toByteArray

      public byte[] toByteArray()
      Converts the Bitmap to a byte array.
      Specified by:
      toByteArray in interface Bitmap
      Returns:
      the byte array representation of the Bitmap.
    • toString

      public String toString()
      Overrides:
      toString in class Object