public class PrefixStringMatcher extends TrieStringMatcher
String
s against a set
of prefixes.TrieStringMatcher.TrieNode
root
Constructor and Description |
---|
PrefixStringMatcher(Collection<String> prefixes)
Creates a new
PrefixStringMatcher which will match
String s with any prefix in the supplied
Collection . |
PrefixStringMatcher(String[] prefixes)
Creates a new
PrefixStringMatcher which will match
String s with any prefix in the supplied array. |
Modifier and Type | Method and Description |
---|---|
String |
longestMatch(String input)
Returns the longest prefix of
input |
static void |
main(String[] argv) |
boolean |
matches(String input)
Returns true if the given
String is matched by a
prefix in the trie |
String |
shortestMatch(String input)
Returns the shortest prefix of
input |
addPatternBackward, addPatternForward, matchChar
public PrefixStringMatcher(String[] prefixes)
PrefixStringMatcher
which will match
String
s with any prefix in the supplied array.
Zero-length Strings
are ignored.public PrefixStringMatcher(Collection<String> prefixes)
PrefixStringMatcher
which will match
String
s with any prefix in the supplied
Collection
.ClassCastException
- if any Object
s in the
collection are not String
spublic boolean matches(String input)
String
is matched by a
prefix in the triematches
in class TrieStringMatcher
public String shortestMatch(String input)
input that is matched,
or null if no match exists.
shortestMatch
in class TrieStringMatcher
public String longestMatch(String input)
input that is matched,
or null if no match exists.
longestMatch
in class TrieStringMatcher
public static final void main(String[] argv)
Copyright © 2014 The Apache Software Foundation