Class TopicsPatternFactory

java.lang.Object
org.apache.pulsar.common.topics.TopicsPatternFactory

public class TopicsPatternFactory extends Object
Factory class for creating instances of TopicsPattern based on different regex implementations. It supports JDK regex, RE2J regex, and a fallback mechanism for RE2J with JDK.
  • Constructor Details

    • TopicsPatternFactory

      public TopicsPatternFactory()
  • Method Details

    • create

      public static TopicsPattern create(Pattern jdkPattern)
      Creates a TopicsPattern from a JDK Pattern. If the pattern contains the topic domain scheme, it will be removed and a RE2J_WITH_JDK_FALLBACK implementation will be used. If the pattern does not contain the topic domain scheme, the input JDK Pattern instance will be used to evaluate topic name matches. The Pulsar Java Client will use this method to create a TopicsPattern from a JDK Pattern.
      Parameters:
      jdkPattern - the JDK Pattern to create the TopicsPattern from
      Returns:
      a TopicsPattern instance
    • create

      public static TopicsPattern create(String regex, TopicsPattern.RegexImplementation implementation)
      Creates a TopicsPattern from a regex string, using the specified regex implementation. The Pulsar Broker will use this method to create a TopicsPattern from a regex string. The implementation is configured in the broker configuration file with the `topicsPatternRegexImplementation` property.
      Parameters:
      regex - the regex string to create the TopicsPattern from
      implementation - the regex implementation to use (RE2J, JDK, or RE2J_WITH_JDK_FALLBACK)
      Returns:
      a TopicsPattern instance
    • matchAll

      public static TopicsPattern matchAll()
      Creates a TopicsPattern that matches all topics.
      Returns:
      a TopicsPattern instance that matches all topics