byte2BitSet static method

IsoBitSet byte2BitSet(
  1. IsoBuffer buffer,
  2. int maxBits
)

Reads a binary bitmap at the buffer's current position without consuming it — the packagers advance the position themselves.

Implementation

static IsoBitSet byte2BitSet(IsoBuffer buffer, int maxBits) {
  final int offset = buffer.position;
  final bool b1 = (buffer.getAt(offset) & 0x80) == 0x80;
  final bool b65 = buffer.limit > offset + 8 && (buffer.getAt(offset + 8) & 0x80) == 0x80;
  final int length = maxBits > 128 && b1 && b65
      ? 192
      : maxBits > 64 && b1
      ? 128
      : maxBits < 64
      ? maxBits
      : 64;
  final IsoBitSet bitSet = IsoBitSet();
  for (int i = 0; i < length; i++) {
    if (buffer.getAt(offset + (i >> 3)) & (0x80 >> i % 8) > 0) bitSet.set(i + 1);
  }
  return bitSet;
}