code: public static int packInt(final byte[] array, final JBBPIntCounter position, final int value) {
      if ((value & 0xFFFFFF80) == 0) {
        array[position.getAndIncrement()] = (byte) value;
        return 1;
      } else if ((value & 0xFFFF0000) == 0) {
        array[position.getAndIncrement()] = (byte) 0x80;
        array[position.getAndIncrement()] = (byte) (value >>> 8);
        array[position.getAndIncrement()] = (byte) value;
        return 3;
      }
      array[position.getAndIncrement()] = (byte) 0x81;
      array[position.getAndIncrement()] = (byte) (value >>> 24);
      array[position.getAndIncrement()] = (byte) (value >>> 16);
      array[position.getAndIncrement()] = (byte) (value >>> 8);
      array[position.getAndIncrement()] = (byte) value;
      return 5;
    }
docs: Pack an integer value and save that into a byte array since defined
  position.
  
  @param array    a byte array where to write the packed data, it must not be
  null
  @param position the position of the first byte of the packed value, it must
  not be null
  @param value    the value to be packed
  @return number of bytes written into the array, the position will be
  increased