code: private static int readCode(boolean[] rawbits, int startIndex, int length) {
      int res = 0;
      for (int i = startIndex; i < startIndex + length; i++) {
        res <<= 1;
        if (rawbits[i]) {
          res |= 0x01;
        }
      }
      return res;
    }
docs: Reads a code of given length and at given index in an array of bits