Package org.apache.nutch.util
Class SuffixStringMatcher
- java.lang.Object
-
- org.apache.nutch.util.TrieStringMatcher
-
- org.apache.nutch.util.SuffixStringMatcher
-
public class SuffixStringMatcher extends TrieStringMatcher
A class for efficiently matchingStrings against a set of suffixes. Zero-lengthStringsare ignored.
-
-
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
Constructors Constructor Description SuffixStringMatcher(String[] suffixes)Creates a newPrefixStringMatcherwhich will matchStrings with any suffix in the supplied array.SuffixStringMatcher(Collection<String> suffixes)Creates a newPrefixStringMatcherwhich will matchStrings with any suffix in the suppliedCollection
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description StringlongestMatch(String input)Returns the longest suffix ofinputthat is matched, ornullif no match exists.static voidmain(String[] argv)booleanmatches(String input)Returns true if the givenStringis matched by a suffix in the trieStringshortestMatch(String input)Returns the shortest suffix ofinputthat is matched, ornullif no match exists.-
Methods inherited from class org.apache.nutch.util.TrieStringMatcher
addPatternBackward, addPatternForward, matchChar
-
-
-
-
Constructor Detail
-
SuffixStringMatcher
public SuffixStringMatcher(String[] suffixes)
Creates a newPrefixStringMatcherwhich will matchStrings with any suffix in the supplied array.- Parameters:
suffixes- A array containing string suffixes
-
SuffixStringMatcher
public SuffixStringMatcher(Collection<String> suffixes)
Creates a newPrefixStringMatcherwhich will matchStrings with any suffix in the suppliedCollection- Parameters:
suffixes- ACollectioncontaining string suffixes
-
-
Method Detail
-
matches
public boolean matches(String input)
Returns true if the givenStringis matched by a suffix 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
public String shortestMatch(String input)
Returns the shortest suffix 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
public String longestMatch(String input)
Returns the longest suffix 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
public static final void main(String[] argv)
-
-