Class PrefixedIntegerCodec

java.lang.Object
io.helidon.common.buffers.PrefixedIntegerCodec

public final class PrefixedIntegerCodec extends Object
Shared codec for HPACK/QPACK prefixed integers.
  • Method Details

    • readInt

      public static int readInt(BufferData source, int firstByte, int prefixBits)
      Read a prefixed integer into an int.
      Parameters:
      source - source buffer positioned after the first byte
      firstByte - first byte of the encoded integer
      prefixBits - number of bits in the first byte reserved for the value, between 1 and 8
      Returns:
      decoded integer value
      Throws:
      IllegalArgumentException - if the prefix width is outside the supported range
    • readLong

      public static long readLong(BufferData source, int firstByte, int prefixBits)
      Read a prefixed integer into a long.
      Parameters:
      source - source buffer positioned after the first byte
      firstByte - first byte of the encoded integer
      prefixBits - number of bits in the first byte reserved for the value, between 1 and 8
      Returns:
      decoded integer value
      Throws:
      IllegalArgumentException - if the prefix width is outside the supported range
    • writeInt

      public static BufferData writeInt(BufferData target, int value, int leadingBits, int prefixBits)
      Write an int prefixed integer.
      Parameters:
      target - target buffer
      value - full non-negative value to write
      leadingBits - bits stored in the first byte outside of the value prefix
      prefixBits - number of bits in the first byte reserved for the value, between 1 and 8
      Returns:
      target buffer
      Throws:
      IllegalArgumentException - if the value or prefix width is outside the supported range
    • writeLong

      public static BufferData writeLong(BufferData target, long value, int leadingBits, int prefixBits)
      Write a long prefixed integer.
      Parameters:
      target - target buffer
      value - full non-negative value to write
      leadingBits - bits stored in the first byte outside of the value prefix
      prefixBits - number of bits in the first byte reserved for the value, between 1 and 8
      Returns:
      target buffer
      Throws:
      IllegalArgumentException - if the value or prefix width is outside the supported range