|
Eclipse Platform Release 3.3 |
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||||
java.lang.Objectorg.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 |
fBreaksOnEOF
Indicates whether end of file terminates the pattern |
protected boolean |
fBreaksOnEOL
Indicates whether end of line terminates 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 boolean |
fEscapeContinuesLine
Indicates whether the escape character continues a line |
protected char[] |
fStartSequence
The pattern's start sequence |
protected IToken |
fToken
The token to be returned on success |
protected static int |
UNDEFINED
Internal setting for the un-initialized column constraint |
| Constructor Summary | |
|---|---|
PatternRule(String startSequence,
String endSequence,
IToken token,
char escapeCharacter,
boolean breaksOnEOL)
Creates a rule for the given starting and ending sequence. |
|
PatternRule(String startSequence,
String endSequence,
IToken token,
char escapeCharacter,
boolean breaksOnEOL,
boolean breaksOnEOF)
Creates a rule for the given starting and ending sequence. |
|
PatternRule(String startSequence,
String endSequence,
IToken token,
char escapeCharacter,
boolean breaksOnEOL,
boolean breaksOnEOF,
boolean escapeContinuesLine)
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 fEscapeContinuesLine
protected boolean fBreaksOnEOL
protected boolean fBreaksOnEOF
| 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 ignoredbreaksOnEOL - indicates whether the end of the line also terminates the pattern
public PatternRule(String startSequence,
String endSequence,
IToken token,
char escapeCharacter,
boolean breaksOnEOL,
boolean breaksOnEOF)
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 ignoredbreaksOnEOL - indicates whether the end of the line also terminates the patternbreaksOnEOF - indicates whether the end of the file also terminates the pattern
public PatternRule(String startSequence,
String endSequence,
IToken token,
char escapeCharacter,
boolean breaksOnEOL,
boolean breaksOnEOF,
boolean escapeContinuesLine)
lineContinuationCharacter will not cause the
pattern to terminate even if breakOnEOL is set to true.
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 ignoredbreaksOnEOL - indicates whether the end of the line also terminates the patternbreaksOnEOF - indicates whether the end of the file also terminates the patternescapeContinuesLine - indicates whether the specified escape character is used for line
continuation, so that an end of line immediately after the escape character does not
terminate the pattern, even if breakOnEOL is set| Method 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)
IRuletrue when calling isUndefined,
if the text that the rule investigated does not match the rule's requirements
evaluate in interface IRulescanner - 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 detected
protected 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 detected
public IToken evaluate(ICharacterScanner scanner,
boolean resume)
IPredicateRuletrue when calling isUndefined,
if the text that 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 IPredicateRulescanner - 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 Release 3.3 |
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||||
Guidelines for using Eclipse APIs.
Copyright (c) IBM Corp. and others 2000, 2007. All rights reserved.