Class TrieStringMatcher

  • Direct Known Subclasses:
    PrefixStringMatcher, SuffixStringMatcher

    public abstract class TrieStringMatcher
    extends Object
    TrieStringMatcher is a base class for simple tree-based string matching. This class is thread-safe during string matching but not when adding strings to the trie.
    • Constructor Detail

      • TrieStringMatcher

        protected TrieStringMatcher()
    • Method Detail

      • addPatternForward

        protected final void addPatternForward​(String s)
        Adds any necessary nodes to the trie so that the given String can be decoded and the last character is represented by a terminal node. Zero-length Strings are ignored.
        Parameters:
        s - String to be decoded.
      • addPatternBackward

        protected final void addPatternBackward​(String s)
        Adds any necessary nodes to the trie so that the given String can be decoded in reverse and the first character is represented by a terminal node. Zero-length Strings are ignored.
        Parameters:
        s - String to be decoded.
      • matches

        public abstract boolean matches​(String input)
        Returns true if the given String is matched by a pattern in the trie
        Parameters:
        input - A String to be matched by a pattern
        Returns:
        true if there is a match, flase otherwise
      • shortestMatch

        public abstract String shortestMatch​(String input)
        Returns the shortest substring of input that is matched by a pattern in the trie, or null if no match exists.
        Parameters:
        input - A String to be matched by a pattern
        Returns:
        shortest string match or null if no match is made
      • longestMatch

        public abstract String longestMatch​(String input)
        Returns the longest substring of input that is matched by a pattern in the trie, or null if no match exists.
        Parameters:
        input - A String to be matched by a pattern
        Returns:
        longest string match or null if no match is made