Package org.firebirdsql.jaybird.parser

## Interface Token

-     @InternalApi
      public interface Token

  A token is an individual element of a SQL statement.

  The available implementations of `Token` are primarily guided by the implementation of the tokenization and the needs of the parser and included visitors. It does not distinguish all types of tokens. For example there is `QuotedIdentifierToken` because the tokenization needs handling for quoted identifiers, while a normal identifier is a `GenericToken`, because that is handled by the fallback tokenization after checking for all other types. On the other hand, open and close curly braces, square brackets and parentheses each have their own type, as the parser may need this to find nested contexts.

  Since:
    5
  Author:
    Mark Rotteveel

- - ### Method Summary

    All Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `default void` | `appendTo​(java.lang.StringBuilder sb)` | Appends the current token to the supplied String builder.
    `default boolean` | `equalsIgnoreCase​(java.lang.String tokenText)` | Case-insensitive equality of this tokens text using an equivalent of `String.equalsIgnoreCase(String)`.
    `default boolean` | `isValidIdentifier()` | Detects if the token is valid as an identifier (ignoring length constraints).
    `default boolean` | `isWhitespaceOrComment()` |
    `int` | `length()` | Token text length.
    `int` | `position()` | Token position.
    `java.lang.String` | `text()` | Token text.
    `default java.lang.CharSequence` | `textAsCharSequence()` | Token text as `CharSequence`.

- - ### Method Detail

    - #### text

          java.lang.String text()

      Token text.
      Returns:
        the text of the token; this is the original text from the source
      See Also:
        `textAsCharSequence()`

    - #### textAsCharSequence

          default java.lang.CharSequence textAsCharSequence()

      Token text as `CharSequence`.

      Default implementation returns `text()`. As an optimization, implementations may return their contained `CharSequence` to avoid unnecessary conversion to string.

      Returns:
        the text of the token; this is the original text from the source
      See Also:
        `text()`

    - #### appendTo

          default void appendTo​(java.lang.StringBuilder sb)

      Appends the current token to the supplied String builder.
      Parameters:
        `sb` - String builder to append to

    - #### position

          int position()

      Token position.
      Returns:
        0-based position of the occurrence of this token in the source (the first character)

    - #### length

          int length()

      Token text length.
      Returns:
        Length of the token text

    - #### isWhitespaceOrComment

          default boolean isWhitespaceOrComment()

      Returns:
        `true` if this token is whitespace or a comment, `false` for all other tokens

    - #### equalsIgnoreCase

          default boolean equalsIgnoreCase​(java.lang.String tokenText)

      Case-insensitive equality of this tokens text using an equivalent of `String.equalsIgnoreCase(String)`.
      Parameters:
        `tokenText` - Token text to compare
      Returns:
        `true` if `tokenText` is equal - ignoring case - to the text of this token, `false` otherwise

    - #### isValidIdentifier

          default boolean isValidIdentifier()

      Detects if the token is valid as an identifier (ignoring length constraints).

      This will always return `false` for `ReservedToken` or other specialised tokens (e.g. `OperatorToken` with `IS` or `LIKE`) that can't occur as an identifier.

      Returns:
        `true` if the token is valid as an identifier, `false` otherwise