Class HuffmanCodec
java.lang.Object
io.helidon.common.buffers.HuffmanCodec
HPACK and QPACK Huffman codec defined by RFC 7541, Appendix B.
-
Method Summary
Modifier and TypeMethodDescriptionstatic intdecode(BufferData source, int encodedLength, byte[] destination) Decode bytes into a destination byte array.static voiddecode(BufferData source, int encodedLength, Appendable destination) Decode bytes into an appendable.static intencode(CharSequence value, byte[] destination) Encode a value into a destination byte array.static intencodedLength(CharSequence value) Calculate the encoded length of a value.
-
Method Details
-
encodedLength
Calculate the encoded length of a value.- Parameters:
value- octet-valued characters to encode- Returns:
- encoded byte count
- Throws:
IllegalArgumentException- if a character is outside the octet range or the encoded length exceeds the supported array range
-
encode
Encode a value into a destination byte array.If encoding is unsuccessful, the destination contents are undefined and must be discarded. A destination that is too small can be detected before all characters have been validated.
- Parameters:
value- octet-valued characters to encodedestination- destination byte array- Returns:
- encoded byte count, or
-1if the destination is too small - Throws:
IllegalArgumentException- if a character is outside the octet range
-
decode
Decode bytes into a destination byte array.Invalid input may partially advance the source and modify the destination. Range and capacity failures are detected before either is modified.
- Parameters:
source- encoded bytesencodedLength- encoded byte countdestination- decoded byte destination- Returns:
- decoded byte count
- Throws:
IndexOutOfBoundsException- if the encoded range exceeds the source or the destination cannot hold the maximum possible decoded valueIllegalArgumentException- if the input is malformed
-
decode
Decode bytes into an appendable.Invalid input or an append failure may partially advance the source and modify the destination. Range failures are detected before either is modified.
- Parameters:
source- encoded bytesencodedLength- encoded byte countdestination- decoded character destination- Throws:
IndexOutOfBoundsException- if the encoded range exceeds the sourceIllegalArgumentException- if the input is malformedUncheckedIOException- if appending fails
-