Package ai.platon.pulsar.common
Class PrefixStringMatcher
-
- All Implemented Interfaces:
public class PrefixStringMatcher extends TrieStringMatcher
A class for efficiently matching
Strings against a set of prefixes.vincent
-
-
Constructor Summary
Constructors Constructor Description PrefixStringMatcher(Array<String> prefixes)Creates a new PrefixStringMatcherwhich will matchStrings with any prefix in the supplied array.PrefixStringMatcher(Collection<String> prefixes)Creates a new PrefixStringMatcherwhich will matchStrings with any prefix in the suppliedCollection.
-
Method Summary
Modifier and Type Method Description final static voidmain(Array<String> argv)main. booleanmatches(String input)Returns true if the given Stringis matched by a pattern in the trie Returns true if the givenStringis matched by a prefix in the trieStringshortestMatch(String input)Returns the shortest substring of inputthat is matched by a pattern in the trie, ornullif no match exists. Returns the shortest prefix ofinputthat is matched, ornullif no match exists.StringlongestMatch(String input)Returns the longest substring of inputthat is matched by a pattern in the trie, ornullif no match exists. Returns the longest prefix ofinputthat is matched, ornullif no match exists.-
-
Constructor Detail
-
PrefixStringMatcher
PrefixStringMatcher(Array<String> prefixes)
Creates a newPrefixStringMatcherwhich will matchStrings with any prefix in the supplied array.- Parameters:
prefixes- an array of java.lang.String objects.
-
PrefixStringMatcher
PrefixStringMatcher(Collection<String> prefixes)
Creates a newPrefixStringMatcherwhich will matchStrings with any prefix in the suppliedCollection.- Parameters:
prefixes- a java.util.Collection object.
-
-
Method Detail
-
main
final static void main(Array<String> argv)
main.
- Parameters:
argv- an array of java.lang.String objects.
-
matches
boolean matches(String input)
Returns true if the given
Stringis matched by a pattern in the trie Returns true if the givenStringis matched by a prefix in the trie
-
shortestMatch
String shortestMatch(String input)
Returns the shortest substring of
inputthat is matched by a pattern in the trie, ornullif no match exists. Returns the shortest prefix ofinputthat is matched, ornullif no match exists.
-
longestMatch
String longestMatch(String input)
Returns the longest substring of
inputthat is matched by a pattern in the trie, ornullif no match exists. Returns the longest prefix ofinputthat is matched, ornullif no match exists.
-
-
-
-