Class NBitIntegerDecoder
- java.lang.Object
-
- org.eclipse.jetty.http.compression.NBitIntegerDecoder
-
public class NBitIntegerDecoder extends java.lang.Object
Used to decode integers as described in RFC7541.
-
-
Constructor Summary
Constructors Constructor Description NBitIntegerDecoder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
decodeInt(java.nio.ByteBuffer buffer)
Decode an integer from the buffer.long
decodeLong(java.nio.ByteBuffer buffer)
Decode a long from the buffer.void
reset()
Reset the internal state of the parser.void
setPrefix(int prefix)
Set the prefix length in of the integer representation in bits.
-
-
-
Method Detail
-
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(java.nio.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 withsetPrefix(int)
.- Parameters:
buffer
- the buffer containing the encoded integer.- Returns:
- the decoded integer or -1 to indicate that more data is needed.
- Throws:
java.lang.ArithmeticException
- if the value overflows a int.
-
decodeLong
public long decodeLong(java.nio.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 withsetPrefix(int)
.- Parameters:
buffer
- the buffer containing the encoded integer.- Returns:
- the decoded long or -1 to indicate that more data is needed.
- Throws:
java.lang.ArithmeticException
- if the value overflows a long.
-
reset
public void reset()
Reset the internal state of the parser.
-
-