|
Eclipse Platform Release 3.6 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.jface.text.rules.WordRule
public class WordRule
An implementation of IRule
capable of detecting words. A word rule also allows to
associate a token to a word. 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
rule uses a word detector to determine what a word is.
IWordDetector
Field Summary | |
---|---|
protected int |
fColumn
The column constraint. |
protected IToken |
fDefaultToken
The default token to be returned on success and if nothing else has been specified. |
protected IWordDetector |
fDetector
The word detector used by this rule. |
protected Map |
fWords
The table of predefined words and token for this rule. |
protected static int |
UNDEFINED
Internal setting for the un-initialized column constraint. |
Constructor Summary | |
---|---|
WordRule(IWordDetector detector)
Creates a rule which, with the help of an word detector, will return the token associated with the detected word. |
|
WordRule(IWordDetector detector,
IToken defaultToken)
Creates a rule which, with the help of a word detector, will return the token associated with the detected word. |
|
WordRule(IWordDetector detector,
IToken defaultToken,
boolean ignoreCase)
Creates a rule which, with the help of a word detector, will return the token associated with the detected word. |
Method Summary | |
---|---|
void |
addWord(String word,
IToken token)
Adds a word and the token to be returned if it is detected. |
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. |
protected void |
unreadBuffer(ICharacterScanner scanner)
Returns the characters in the buffer to the scanner. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final int UNDEFINED
protected IWordDetector fDetector
protected IToken fDefaultToken
protected int fColumn
protected Map fWords
Constructor Detail |
---|
public WordRule(IWordDetector detector)
detector
- the word detector to be used by this rule, may not be null
addWord(String, IToken)
public WordRule(IWordDetector detector, IToken defaultToken)
detector
- the word detector to be used by this rule, may not be null
defaultToken
- the default token to be returned on success
if nothing else is specified, may not be null
addWord(String, IToken)
public WordRule(IWordDetector detector, IToken defaultToken, boolean ignoreCase)
detector
- the word detector to be used by this rule, may not be null
defaultToken
- the default token to be returned on success
if nothing else is specified, may not be null
ignoreCase
- the case sensitivity associated with this ruleaddWord(String, IToken)
Method Detail |
---|
public void addWord(String word, IToken token)
word
- the word this rule will search for, may not be null
token
- the token to be returned if the word has been found, may not be null
public void setColumnConstraint(int column)
column
- the column in which the pattern startspublic IToken evaluate(ICharacterScanner scanner)
IRule
true
when calling
isUndefined
, if the text that the rule investigated does not match the rule's
requirements
evaluate
in interface IRule
scanner
- the character scanner to be used by this rule
protected void unreadBuffer(ICharacterScanner scanner)
scanner
- the scanner to be used
|
Eclipse Platform Release 3.6 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Guidelines for using Eclipse APIs.
Copyright (c) Eclipse contributors and others 2000, 2010. All rights reserved.