Class MqttTopic

java.lang.Object
com.codename1.io.mqtt.MqttTopic

public final class MqttTopic extends Object
Topic names and topic filters: validation and the + / # matching rules of MQTT 3.1.1 section 4.7.
  • Method Details

    • validateName

      public static void validateName(String topic)

      Checks a topic name, the thing a message is published to.

      Parameters
      • topic: the name
      Throws

      IllegalArgumentException when it is empty, contains a wildcard, a NUL character, or is longer than 65535 UTF-8 bytes

    • validateFilter

      public static void validateFilter(String filter)

      Checks a topic filter, the thing a subscription is made with.

      Parameters
      • filter: the filter
      Throws

      IllegalArgumentException when it is empty, has a + that is not a whole level, a # that is not the whole last level, or a NUL character

    • matches

      public static boolean matches(String filter, String topic)

      Tells whether a topic name matches a topic filter. A filter that starts with a wildcard does not match a name that starts with $.

      Parameters
      • filter: a valid topic filter

      • topic: a valid topic name

      Returns

      true when the name is covered by the filter