public class CombinedWordRule extends java.lang.Object implements IRule
IRule capable of detecting words.
Word rules also allow for the association of tokens with specific words. That is, not only can the rule be used to provide tokens for exact matches, but also for the generalized notion of a word in the context in which it is used. A word rules uses a word detector to determine what a word is.
This word rule allows a word detector to be shared among different word matchers. Its up to the word matchers to decide if a word matches and, in this a case, which token is associated with that word.
IWordDetector| Modifier and Type | Class and Description |
|---|---|
static class |
CombinedWordRule.CharacterBuffer
Character buffer, mutable or suitable for use as key in hash maps.
|
static class |
CombinedWordRule.WordMatcher
Word matcher, that associates matched words with tokens.
|
| Constructor and Description |
|---|
CombinedWordRule(IWordDetector detector)
Creates a rule which, with the help of an word detector, will return the token
associated with the detected word.
|
CombinedWordRule(IWordDetector detector,
CombinedWordRule.WordMatcher matcher)
Creates a rule which, with the help of an word detector, will return the token
associated with the detected word.
|
CombinedWordRule(IWordDetector detector,
CombinedWordRule.WordMatcher matcher,
IToken defaultToken)
Creates a rule which, with the help of an word detector, will return the token
associated with the detected word.
|
CombinedWordRule(IWordDetector detector,
IToken defaultToken)
Creates a rule which, with the help of an word detector, will return the token
associated with the detected word.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addWordMatcher(CombinedWordRule.WordMatcher matcher)
Adds the given matcher.
|
IToken |
evaluate(ICharacterScanner scanner)
Evaluates the rule by examining the characters available from the provided character scanner.
|
void |
setColumnConstraint(int column)
Sets a column constraint for this rule.
|
public CombinedWordRule(IWordDetector detector)
detector - the word detector to be used by this rule, may not be nullCombinedWordRule.WordMatcher.addWord(String, IToken)public CombinedWordRule(IWordDetector detector, IToken defaultToken)
detector - the word detector to be used by this rule, may not be nulldefaultToken - the default token to be returned on success
if nothing else is specified, may not be nullCombinedWordRule.WordMatcher.addWord(String, IToken)public CombinedWordRule(IWordDetector detector, CombinedWordRule.WordMatcher matcher)
detector - the word detector to be used by this rule, may not be nullmatcher - the initial word matcherCombinedWordRule.WordMatcher.addWord(String, IToken)public CombinedWordRule(IWordDetector detector, CombinedWordRule.WordMatcher matcher, IToken defaultToken)
detector - the word detector to be used by this rule, may not be nullmatcher - the initial word matcherdefaultToken - the default token to be returned on success
if nothing else is specified, may not be nullCombinedWordRule.WordMatcher.addWord(String, IToken)public void addWordMatcher(CombinedWordRule.WordMatcher matcher)
matcher - the matcherpublic void setColumnConstraint(int column)
column - the column in which the pattern startspublic IToken evaluate(ICharacterScanner scanner)
IRuletrue when calling
isUndefined, if the text that the rule investigated does not match the rule's
requirements