org.apache.nutch.util
Class PrefixStringMatcher
java.lang.Object
org.apache.nutch.util.TrieStringMatcher
org.apache.nutch.util.PrefixStringMatcher
public class PrefixStringMatcher
- extends TrieStringMatcher
A class for efficiently matching String
s against a set
of prefixes.
Constructor Summary |
PrefixStringMatcher(Collection 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. |
Method Summary |
String |
longestMatch(String input)
Returns the longest prefix of input that is matched,
or null if no match exists. |
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 that is matched,
or null if no match exists. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
PrefixStringMatcher
public PrefixStringMatcher(String[] prefixes)
- Creates a new
PrefixStringMatcher
which will match
String
s with any prefix in the supplied array.
Zero-length Strings
are ignored.
PrefixStringMatcher
public PrefixStringMatcher(Collection prefixes)
- Creates a new
PrefixStringMatcher
which will match
String
s with any prefix in the supplied
Collection
.
- Throws:
ClassCastException
- if any Object
s in the
collection are not String
s
matches
public boolean matches(String input)
- Returns true if the given
String
is matched by a
prefix in the trie
- Specified by:
matches
in class TrieStringMatcher
shortestMatch
public String shortestMatch(String input)
- Returns the shortest prefix of
input that is matched,
or null if no match exists.
- Specified by:
shortestMatch
in class TrieStringMatcher
longestMatch
public String longestMatch(String input)
- Returns the longest prefix of
input that is matched,
or null if no match exists.
- Specified by:
longestMatch
in class TrieStringMatcher
main
public static final void main(String[] argv)
Copyright © 2012 The Apache Software Foundation