Package org.apache.nutch.util
Class PrefixStringMatcher
java.lang.Object
org.apache.nutch.util.TrieStringMatcher
org.apache.nutch.util.PrefixStringMatcher
A class for efficiently matching
Strings against a set of
prefixes.-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.nutch.util.TrieStringMatcher
TrieStringMatcher.TrieNode -
Field Summary
Fields inherited from class org.apache.nutch.util.TrieStringMatcher
root -
Constructor Summary
ConstructorsConstructorDescriptionPrefixStringMatcher(String[] prefixes) Creates a newPrefixStringMatcherwhich will matchStrings with any prefix in the supplied array.PrefixStringMatcher(Collection<String> prefixes) Creates a newPrefixStringMatcherwhich will matchStrings with any prefix in the suppliedCollection. -
Method Summary
Modifier and TypeMethodDescriptionlongestMatch(String input) Returns the longest prefix ofinputthat is matched, ornullif no match exists.static final voidbooleanReturns true if the givenStringis matched by a prefix in the trieshortestMatch(String input) Returns the shortest prefix ofinputthat is matched, ornullif no match exists.Methods inherited from class org.apache.nutch.util.TrieStringMatcher
addPatternBackward, addPatternForward, matchChar
-
Constructor Details
-
PrefixStringMatcher
Creates a newPrefixStringMatcherwhich will matchStrings with any prefix in the supplied array. Zero-lengthStringsare ignored.- Parameters:
prefixes- A array containing string prefixes
-
PrefixStringMatcher
Creates a newPrefixStringMatcherwhich will matchStrings with any prefix in the suppliedCollection.- Parameters:
prefixes- A collection containing string prefixes- Throws:
ClassCastException- if anyObjects in the collection are notStrings
-
-
Method Details
-
matches
Returns true if the givenStringis matched by a prefix in the trie- Specified by:
matchesin classTrieStringMatcher- Parameters:
input- A String to be matched by a pattern- Returns:
- true if there is a match, flase otherwise
-
shortestMatch
Returns the shortest prefix ofinputthat is matched, ornullif no match exists.- Specified by:
shortestMatchin classTrieStringMatcher- Parameters:
input- A String to be matched by a pattern- Returns:
- shortest string match or null if no match is made
-
longestMatch
Returns the longest prefix ofinputthat is matched, ornullif no match exists.- Specified by:
longestMatchin classTrieStringMatcher- Parameters:
input- A String to be matched by a pattern- Returns:
- longest string match or null if no match is made
-
main
-