## org.eclipse.datatools.sqltools.sqleditor.internal.matching
Class AbstractPairMatcher

    java.lang.Object
      org.eclipse.datatools.sqltools.sqleditor.internal.matching.AbstractPairMatcher

All Implemented Interfaces:
  org.eclipse.jface.text.source.ICharacterPairMatcher

Direct Known Subclasses:
  GeneralPairMatcher, GenericSQLPairMatcher

    public abstract class AbstractPairMatcher

extends java.lang.Object
implements org.eclipse.jface.text.source.ICharacterPairMatcher

Abstract token matcher which provides token matching methods and some abstract methods to dedicate themselves to complete matching methods.
If you want to support token matching for a specific SQL language, you need to extend this class, and implements all abstract methods as its function target.

Author:
  juewu

Field Summary

Fields inherited from interface org.eclipse.jface.text.source.ICharacterPairMatcher
`LEFT, RIGHT`

Constructor Summary
`AbstractPairMatcher(IMatchingPairs matchingPairs)`

Method Summary
`void` `clear()`
`void` `dispose()`
`int` `getAnchor()`
`abstract int` `getMatchingTokenLength()` Getting the token of the token which matches with the selected token.
`abstract int` `getMatchingTokenStartOffset(java.lang.String token, int start, boolean forward, java.lang.String text)` Getting the start offset of the matching token.
`abstract java.lang.String` `getOriginalToken(java.lang.String text, int offset)` Getting the token according to selected position.
`abstract int` `getOriginalTokenEndOffset(java.lang.String text, int offset)` Getting the end offset of selected token.
`abstract int` `getOriginalTokenLength()` Getting the length of the token which is get from getOriginalToken method.
`SQLEditor` `getSQLEditor()`
`org.eclipse.jface.text.IRegion` `match(org.eclipse.jface.text.IDocument doc, int offset)`
`void` `setSQLEditor(SQLEditor editor)`

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### AbstractPairMatcher

    public AbstractPairMatcher(IMatchingPairs matchingPairs)

Method Detail

### clear

    public void clear()

  Specified by:
    `clear` in interface `org.eclipse.jface.text.source.ICharacterPairMatcher`

### dispose

    public void dispose()

  Specified by:
    `dispose` in interface `org.eclipse.jface.text.source.ICharacterPairMatcher`

### getAnchor

    public int getAnchor()

  Specified by:
    `getAnchor` in interface `org.eclipse.jface.text.source.ICharacterPairMatcher`

### match

    public org.eclipse.jface.text.IRegion match(org.eclipse.jface.text.IDocument doc,
                                                int offset)

  Specified by:
    `match` in interface `org.eclipse.jface.text.source.ICharacterPairMatcher`

### getSQLEditor

    public SQLEditor getSQLEditor()

### setSQLEditor

    public void setSQLEditor(SQLEditor editor)

### getOriginalToken

    public abstract java.lang.String getOriginalToken(java.lang.String text,
                                                      int offset)

  Getting the token according to selected position.

  Parameters:
    `text` - is the document text.
    `offset` - is the selected position.
  Returns:
    If supported token exists, return this token. Otherwise return null.

### getOriginalTokenLength

    public abstract int getOriginalTokenLength()

  Getting the length of the token which is get from getOriginalToken method.

  Returns:
    the token length.

### getMatchingTokenLength

    public abstract int getMatchingTokenLength()

  Getting the token of the token which matches with the selected token.

  Returns:
    a `int` represents the matching token length.

### getOriginalTokenEndOffset

    public abstract int getOriginalTokenEndOffset(java.lang.String text,
                                                  int offset)

  Getting the end offset of selected token.

  Parameters:
    `text` - is the document text.
    `offset` - is the selected position.
  Returns:
    a `int` which is end offset of selected token.

### getMatchingTokenStartOffset

    public abstract int getMatchingTokenStartOffset(java.lang.String token,
                                                    int start,
                                                    boolean forward,
                                                    java.lang.String text)

  Getting the start offset of the matching token.

  Parameters:
    `token` - is a `String` represents the selected token.
    `start` - is the selected token end offset.
    `forward` - represents searching forward or back ward.
    `text` - is the document text.
  Returns:
    If the matching token exists, return its start offset. Otherwise, return -1;