Class PrefixedStringEncoder

    • Field Detail

      • DEFAULT_PREFIX_LENGTH

        public static final int DEFAULT_PREFIX_LENGTH
        The default length for the prefix
        See Also:
        Constant Field Values
      • DEFAULT_MAX_DATA_LENGTH

        public static final int DEFAULT_MAX_DATA_LENGTH
        The default maximum data length
        See Also:
        Constant Field Values
    • Constructor Detail

      • PrefixedStringEncoder

        public PrefixedStringEncoder​(Charset charset,
                                     int prefixLength,
                                     int maxDataLength)
        Creates a new PrefixedStringEncoder instance
        Parameters:
        charset - the Charset to use for encoding
        prefixLength - the length of the prefix
        maxDataLength - maximum number of bytes allowed for a single String
      • PrefixedStringEncoder

        public PrefixedStringEncoder​(Charset charset,
                                     int prefixLength)
        Creates a new PrefixedStringEncoder instance
        Parameters:
        charset - the Charset to use for encoding
        prefixLength - the length of the prefix
      • PrefixedStringEncoder

        public PrefixedStringEncoder​(Charset charset)
        Creates a new PrefixedStringEncoder instance
        Parameters:
        charset - the Charset to use for encoding
      • PrefixedStringEncoder

        public PrefixedStringEncoder()
        Creates a new PrefixedStringEncoder instance
    • Method Detail

      • setPrefixLength

        public void setPrefixLength​(int prefixLength)
        Sets the number of bytes used by the length prefix
        Parameters:
        prefixLength - the length of the length prefix (1, 2, or 4)
      • getPrefixLength

        public int getPrefixLength()
        Gets the length of the length prefix (1, 2, or 4)
        Returns:
        length of the length prefix
      • setMaxDataLength

        public void setMaxDataLength​(int maxDataLength)
        Sets the maximum number of bytes allowed for encoding a single String (including the prefix)

        The encoder will throw a IllegalArgumentException when more bytes are needed to encode a String value. The default value is DEFAULT_MAX_DATA_LENGTH.

        Parameters:
        maxDataLength - maximum number of bytes allowed for encoding a single String
      • getMaxDataLength

        public int getMaxDataLength()
        Gets the maximum number of bytes allowed for encoding a single String *
        Returns:
        maximum number of bytes allowed for encoding a single String (prefix included)