|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.nutch.util.TrieStringMatcher
public abstract class TrieStringMatcher
TrieStringMatcher is a base class for simple tree-based string matching.
| Nested Class Summary | |
|---|---|
protected class |
TrieStringMatcher.TrieNode
Node class for the character tree. |
| Field Summary | |
|---|---|
protected TrieStringMatcher.TrieNode |
root
|
| Constructor Summary | |
|---|---|
protected |
TrieStringMatcher()
|
| Method Summary | |
|---|---|
protected void |
addPatternBackward(String s)
Adds any necessary nodes to the trie so that the given String can be decoded in reverse and the
first character is represented by a terminal node. |
protected void |
addPatternForward(String s)
Adds any necessary nodes to the trie so that the given String can be decoded and the last character is
represented by a terminal node. |
abstract String |
longestMatch(String input)
Returns the longest substring of input |
protected TrieStringMatcher.TrieNode |
matchChar(TrieStringMatcher.TrieNode node,
String s,
int idx)
Returns the next TrieStringMatcher.TrieNode visited, given that you are at
node, and the the next character in the input is
the idx'th character of s. |
abstract boolean |
matches(String input)
Returns true if the given String is matched by a
pattern in the trie |
abstract String |
shortestMatch(String input)
Returns the shortest substring of input |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected TrieStringMatcher.TrieNode root
| Constructor Detail |
|---|
protected TrieStringMatcher()
| Method Detail |
|---|
protected final TrieStringMatcher.TrieNode matchChar(TrieStringMatcher.TrieNode node,
String s,
int idx)
TrieStringMatcher.TrieNode visited, given that you are at
node, and the the next character in the input is
the idx'th character of s.
protected final void addPatternForward(String s)
String can be decoded and the last character is
represented by a terminal node. Zero-length Strings
are ignored.
protected final void addPatternBackward(String s)
String can be decoded in reverse and the
first character is represented by a terminal node. Zero-length
Strings are ignored.
public abstract boolean matches(String input)
String is matched by a
pattern in the trie
public abstract String shortestMatch(String input)
input that is
matched by a pattern in the trie, or null if no match
exists.
public abstract String longestMatch(String input)
input that is
matched by a pattern in the trie, or null if no match
exists.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||