Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Eclipse Platform Release 3.0
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.eclipse.jface.text.rules
Class PatternRule

    java.lang.Object
      org.eclipse.jface.text.rules.PatternRule

All Implemented Interfaces:
  IPredicateRule, IRule

Direct Known Subclasses:
  MultiLineRule, SingleLineRule

public class PatternRule
extends Object
implements IPredicateRule

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 uninitialized 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

### UNDEFINED

    protected static final int UNDEFINED

  Internal setting for the uninitialized column constraint

  See Also:
    Constant Field Values

### fToken

    protected IToken fToken

  The token to be returned on success

### fStartSequence

    protected char[] fStartSequence

  The pattern's start sequence

### fEndSequence

    protected char[] fEndSequence

  The pattern's end sequence

### fColumn

    protected int fColumn

  The pattern's column constrain

### fEscapeCharacter

    protected char fEscapeCharacter

  The pattern's escape character

### fEscapeContinuesLine

    protected boolean fEscapeContinuesLine

  Indicates whether the escape character continues a line

  Since:
    3.0

### fBreaksOnEOL

    protected boolean fBreaksOnEOL

  Indicates whether end of line terminates the pattern

### fBreaksOnEOF

    protected boolean fBreaksOnEOF

  Indicates whether end of file terminates the pattern

Constructor Detail

### PatternRule

    public PatternRule(String startSequence,
                       String endSequence,
                       IToken token,
                       char escapeCharacter,
                       boolean breaksOnEOL)

  Creates a rule for the given starting and ending sequence. When these sequences are detected the rule will return the specified token. Alternatively, the sequence can also be ended by the end of the line. Any character which follows the given escapeCharacter will be ignored.

Parameters:
  `startSequence` - the pattern's start sequence
  `endSequence` - the pattern's end sequence, `null` is a legal value
  `token` - the token which will be returned on success
  `escapeCharacter` - any character following this one will be ignored
  `breaksOnEOL` - indicates whether the end of the line also terminates the pattern

### PatternRule

    public PatternRule(String startSequence,
                       String endSequence,
                       IToken token,
                       char escapeCharacter,
                       boolean breaksOnEOL,
                       boolean breaksOnEOF)

  Creates a rule for the given starting and ending sequence. When these sequences are detected the rule will return the specified token. Alternatively, the sequence can also be ended by the end of the line or the end of the file. Any character which follows the given escapeCharacter will be ignored.

Parameters:
  `startSequence` - the pattern's start sequence
  `endSequence` - the pattern's end sequence, `null` is a legal value
  `token` - the token which will be returned on success
  `escapeCharacter` - any character following this one will be ignored
  `breaksOnEOL` - indicates whether the end of the line also terminates the pattern
  `breaksOnEOF` - indicates whether the end of the file also terminates the pattern
Since:
  2.1

### PatternRule

    public 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. When these sequences are detected the rule will return the specified token. Alternatively, the sequence can also be ended by the end of the line or the end of the file. Any character which follows the given escapeCharacter will be ignored. An end of line immediately after the given `lineContinuationCharacter` will not cause the pattern to terminate even if `breakOnEOL` is set to true.

Parameters:
  `startSequence` - the pattern's start sequence
  `endSequence` - the pattern's end sequence, `null` is a legal value
  `token` - the token which will be returned on success
  `escapeCharacter` - any character following this one will be ignored
  `breaksOnEOL` - indicates whether the end of the line also terminates the pattern
  `breaksOnEOF` - indicates whether the end of the file also terminates the pattern
  `escapeContinuesLine` - 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
Since:
  3.0

Method Detail

### setColumnConstraint

    public void setColumnConstraint(int column)

  Sets a column constraint for this rule. If set, the rule's token will only be returned if the pattern is detected starting at the specified column. If the column is smaller then 0, the column constraint is considered removed.

  Parameters:
    `column` - the column in which the pattern starts

### doEvaluate

    protected IToken doEvaluate(ICharacterScanner scanner)

  Evaluates this rules without considering any column constraints.

  Parameters:
    `scanner` - the character scanner to be used
  Returns:
    the token resulting from this evaluation

### doEvaluate

    protected IToken doEvaluate(ICharacterScanner scanner,
                                boolean resume)

  Evaluates this rules without considering any column constraints. Resumes detection, i.e. look sonly for the end sequence required by this rule if the `resume` flag is set.

  Parameters:
    `scanner` - the character scanner to be used
    `resume` - `true` if detection should be resumed, `false` otherwise
  Returns:
    the token resulting from this evaluation
  Since:
    2.0

### evaluate

    public IToken evaluate(ICharacterScanner scanner)

  Description copied from interface: `IRule`
  Evaluates the rule by examining the characters available from the provided character scanner. The token returned by this rule returns `true` when calling `isUndefined`, if the text the rule investigated does not match the rule's requirements.

  Specified by:
    `evaluate` in interface `IRule`
  Parameters:
    `scanner` - the character scanner to be used by this rule
  Returns:
    the token computed by the rule

### endSequenceDetected

    protected boolean endSequenceDetected(ICharacterScanner scanner)

  Returns whether the end sequence was detected. As the pattern can be considered ended by a line delimiter, the result of this method is `true` if the rule breaks on the end of the line, or if the EOF character is read.

  Parameters:
    `scanner` - the character scanner to be used
  Returns:
    `true` if the end sequence has been detected

### sequenceDetected

    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. No escape characters are allowed within the sequence. If specified the sequence is considered to be found when reading the EOF character.

  Parameters:
    `scanner` - the character scanner to be used
    `sequence` - the sequence to be detected
    `eofAllowed` - indicated whether EOF terminates the pattern
  Returns:
    `true` if the given sequence has been detected

### evaluate

    public IToken evaluate(ICharacterScanner scanner,
                           boolean resume)

  Description copied from interface: `IPredicateRule`
  Evaluates the rule by examining the characters available from the provided character scanner. The token returned by this rule returns `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`.

  Specified by:
    `evaluate` in interface `IPredicateRule`
  Parameters:
    `scanner` - the character scanner to be used by this rule
    `resume` - indicates that the rule starts working between the opening and the closing character sequence
  Returns:
    the token computed by the rule

### getSuccessToken

    public IToken getSuccessToken()

  Description copied from interface: `IPredicateRule`
  Returns the success token of this predicate rule.

  Specified by:
    `getSuccessToken` in interface `IPredicateRule`
  Returns:
    the success token of this rule

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Eclipse Platform Release 3.0
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, 2004. All rights reserved.