public abstract class TrieStringMatcher
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
protected class |
TrieStringMatcher.TrieNode
Node class for the character tree.
|
Modifier and Type | Field and Description |
---|---|
protected TrieStringMatcher.TrieNode |
root |
Modifier | Constructor and Description |
---|---|
protected |
TrieStringMatcher() |
Modifier and Type | Method and Description |
---|---|
protected void |
addPatternBackward(java.lang.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(java.lang.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 java.lang.String |
longestMatch(java.lang.String input)
Returns the longest substring of
input that is
matched by a pattern in the trie, or null if no match
exists. |
protected TrieStringMatcher.TrieNode |
matchChar(TrieStringMatcher.TrieNode node,
java.lang.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(java.lang.String input)
Returns true if the given
String is matched by a pattern in
the trie |
abstract java.lang.String |
shortestMatch(java.lang.String input)
Returns the shortest substring of
input that is
matched by a pattern in the trie, or null if no match
exists. |
protected TrieStringMatcher.TrieNode root
protected final TrieStringMatcher.TrieNode matchChar(TrieStringMatcher.TrieNode node, java.lang.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(java.lang.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(java.lang.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(java.lang.String input)
String
is matched by a pattern in
the triepublic abstract java.lang.String shortestMatch(java.lang.String input)
input
that is
matched by a pattern in the trie, or null
if no match
exists.public abstract java.lang.String longestMatch(java.lang.String input)
input
that is
matched by a pattern in the trie, or null
if no match
exists.Copyright © 2019 The Apache Software Foundation