Interface MqttUtf8String

All Superinterfaces:
Comparable<MqttUtf8String>
All Known Subinterfaces:
MqttClientIdentifier, MqttSharedTopicFilter, MqttTopic, MqttTopicFilter

@DoNotImplement public interface MqttUtf8String extends Comparable<MqttUtf8String>
UTF-8 encoded string according to the MQTT specification.

MUST requirements: An UTF-8 encoded string

  • must not be longer than 65535 bytes in UTF-8 encoding,
  • must not contain the null character (U+0000) and
  • must be well-formed UTF-8 as defined by the Unicode specification, so
    • must not contain encodings of UTF-16 surrogates (U+D800..U+DFFF) and
    • must not contain non-shortest form encodings.

SHOULD requirements: An UTF-8 encoded string

  • should not contain control characters (U+0001..U+001F, U+007F..U+009F) and
  • should not contain non-characters.
Since:
1.0
  • Method Details

    • of

      Validates and creates an UTF-8 encoded string of the given Java string.
      Parameters:
      string - the string representation of the UTF-8 encoded string.
      Returns:
      the created UTF-8 encoded string.
      Throws:
      IllegalArgumentException - if the string is not a valid UTF-8 encoded string.
    • containsShouldNotCharacters

      boolean containsShouldNotCharacters()
      Checks whether this UTF-8 encoded string contains characters that it should not according to the MQTT specification.

      These characters are control characters (U+0001..U+001F, U+007F..U+009F) and non-characters.

      Returns:
      whether this UTF-8 encoded string contains characters that it should not.
    • toByteBuffer

      @NotNull @NotNull ByteBuffer toByteBuffer()
      Returns the UTF-8 encoded representation as a read-only byte buffer.
      Returns:
      the UTF-8 encoded read-only byte buffer.