Class NBitStringDecoder


  • public class NBitStringDecoder
    extends java.lang.Object

    Used to decode string literals as described in RFC7541.

    The string literal representation consists of a single bit to indicate whether huffman encoding is used, followed by the string byte length encoded with the n-bit integer representation also from RFC7541, and the bytes of the string are directly after this.

    Characters which are illegal field-vchar values are replaced with either ' ' or '?' as described in RFC9110

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String decode​(java.nio.ByteBuffer buffer)
      Decode a string from the buffer.
      void reset()  
      void setPrefix​(int prefix)
      Set the prefix length in of the string representation in bits.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • NBitStringDecoder

        public NBitStringDecoder()
    • Method Detail

      • setPrefix

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

        public java.lang.String decode​(java.nio.ByteBuffer buffer)
                                throws EncodingException
        Decode a string from the buffer. If the buffer does not contain the complete string representation then a value of null 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 string.
        Returns:
        the decoded string or null to indicate that more data is needed.
        Throws:
        java.lang.ArithmeticException - if the string length value overflows a int.
        EncodingException - if the string encoding is invalid.
      • reset

        public void reset()