|
Eclipse Platform 2.0 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.eclipse.jface.text.rules.PatternRule
Standard implementation of IPredicateRule
.
Is is capable of detecting a pattern which begins with a given start
sequence and ends with a given end sequence. If the end sequence is
not specified, it can be either end of line, end or file, or both. Additionally,
the pattern can be constrained to begin in a certain column. The rule can also
be used to check whether the text to scan covers half of the pattern, i.e. contains
the end sequence required by the rule.
Field Summary | |
protected boolean |
fBreaksOnEOL
Indicates whether end of line termines the pattern |
protected int |
fColumn
The pattern's column constrain |
protected char[] |
fEndSequence
The pattern's end sequence |
protected char |
fEscapeCharacter
The pattern's escape character |
protected char[] |
fStartSequence
The pattern's start sequence |
protected IToken |
fToken
The token to be returned on success |
protected static int |
UNDEFINED
|
Constructor Summary | |
PatternRule(String startSequence,
String endSequence,
IToken token,
char escapeCharacter,
boolean breaksOnEOL)
Creates a rule for the given starting and ending sequence. |
Method Summary | |
protected IToken |
doEvaluate(ICharacterScanner scanner)
Evaluates this rules without considering any column constraints. |
protected IToken |
doEvaluate(ICharacterScanner scanner,
boolean resume)
Evaluates this rules without considering any column constraints. |
protected boolean |
endSequenceDetected(ICharacterScanner scanner)
Returns whether the end sequence was detected. |
IToken |
evaluate(ICharacterScanner scanner)
Evaluates the rule by examining the characters available from the provided character scanner. |
IToken |
evaluate(ICharacterScanner scanner,
boolean resume)
Evaluates the rule by examining the characters available from the provided character scanner. |
IToken |
getSuccessToken()
Returns the success token of this predicate rule. |
protected boolean |
sequenceDetected(ICharacterScanner scanner,
char[] sequence,
boolean eofAllowed)
Returns whether the next characters to be read by the character scanner are an exact match with the given sequence. |
void |
setColumnConstraint(int column)
Sets a column constraint for this rule. |
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 IToken fToken
protected char[] fStartSequence
protected char[] fEndSequence
protected int fColumn
protected char fEscapeCharacter
protected boolean fBreaksOnEOL
Constructor Detail |
public PatternRule(String startSequence, String endSequence, IToken token, char escapeCharacter, boolean breaksOnEOL)
startSequence
- the pattern's start sequenceendSequence
- the pattern's end sequence, null
is a legal valuetoken
- the token which will be returned on successescapeCharacter
- any character following this one will be ignoredMethod Detail |
public void setColumnConstraint(int column)
column
- the column in which the pattern startsprotected IToken doEvaluate(ICharacterScanner scanner)
scanner
- the character scanner to be used
protected IToken doEvaluate(ICharacterScanner scanner, boolean resume)
resume
flag is set.
scanner
- the character scanner to be usedresume
- true
if detection should be resumed, false
otherwise
public IToken evaluate(ICharacterScanner scanner)
IRule
true
when calling isUndefined
,
if the text 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 boolean endSequenceDetected(ICharacterScanner scanner)
true
if the
rule breaks on the end of the line, or if the EOF character is read.
scanner
- the character scanner to be used
true
if the end sequence has been detectedprotected boolean sequenceDetected(ICharacterScanner scanner, char[] sequence, boolean eofAllowed)
scanner
- the character scanner to be usedsequence
- the sequence to be detectedeofAllowed
- indicated whether EOF terminates the pattern
true
if the given sequence has been detectedpublic IToken evaluate(ICharacterScanner scanner, boolean resume)
IPredicateRule
true
when calling isUndefined
,
if the text the rule investigated does not match the rule's requirements. Otherwise,
this method returns this rule's success token. If this rules relies on a text pattern
comprising a opening and a closing character sequence this method can also be called
when the scanner is positioned already between the opening and the closing sequence.
In this case, resume
must be set to true
.
evaluate
in interface IPredicateRule
scanner
- the character scanner to be used by this ruleresume
- indicates that the rule starts working between the opening and the closing character sequence
public IToken getSuccessToken()
IPredicateRule
getSuccessToken
in interface IPredicateRule
|
Eclipse Platform 2.0 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |