Class NBitIntegerDecoder

java.lang.Object
org.eclipse.jetty.http.compression.NBitIntegerDecoder

public class NBitIntegerDecoder extends Object
Used to decode integers as described in RFC7541.
  • Constructor Details

    • NBitIntegerDecoder

      public NBitIntegerDecoder()
  • Method Details

    • setPrefix

      public void setPrefix(int prefix)
      Set the prefix length in of the integer representation in bits. A prefix of 6 means the integer representation starts after the first 2 bits.
      Parameters:
      prefix - the number of bits in the integer prefix.
    • decodeInt

      public int decodeInt(ByteBuffer buffer)
      Decode an integer from the buffer. If the buffer does not contain the complete integer representation a value of -1 is returned to indicate that more data is needed to complete parsing. This should be only after the prefix has been set with setPrefix(int).
      Parameters:
      buffer - the buffer containing the encoded integer.
      Returns:
      the decoded integer or -1 to indicate that more data is needed.
      Throws:
      ArithmeticException - if the value overflows a int.
    • decodeLong

      public long decodeLong(ByteBuffer buffer)
      Decode a long from the buffer. If the buffer does not contain the complete integer representation a value of -1 is returned to indicate that more data is needed to complete parsing. This should be only after the prefix has been set with setPrefix(int).
      Parameters:
      buffer - the buffer containing the encoded integer.
      Returns:
      the decoded long or -1 to indicate that more data is needed.
      Throws:
      ArithmeticException - if the value overflows a long.
    • reset

      public void reset()
      Reset the internal state of the parser.