org.modeshape.common.text

## Interface TokenStream.Token

- All Known Implementing Classes:
    TokenStream.CaseInsensitiveToken, TokenStream.CaseSensitiveToken
  Enclosing class:
    TokenStream

      @Immutable
      public static interface TokenStream.Token

  The interface defining a token, which references the characters in the actual input character stream.
  See Also:
    `TokenStream.CaseSensitiveTokenFactory`, `TokenStream.CaseInsensitiveTokenFactory`

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `endIndex()` Get the index in the raw stream past the last character in the token.
    `int` | `length()` Get the length of the token, which is equivalent to `endIndex() - startIndex()`.
    `boolean` | `matches(char expected)` Determine if the token matches the supplied character.
    `boolean` | `matches(int expectedType)` Determine if the token matches the supplied type.
    `boolean` | `matches(String expected)` Determine if the token matches the supplied string.
    `Position` | `position()` Get the position of this token, which includes the line number and column number of the first character in the token.
    `int` | `startIndex()` Get the index in the raw stream for the first character in the token.
    `int` | `type()` Get the type of the token.
    `String` | `value()` Get the value of the token, in actual case.
    `TokenStream.Token` | `withType(int typeMask)` Bitmask ORed with existing type value.

- - ### Method Detail

    - #### value

          String value()

      Get the value of the token, in actual case.
      Returns:
        the value

    - #### matches

          boolean matches(String expected)

      Determine if the token matches the supplied string.
      Parameters:
        `expected` - the expected value
      Returns:
        true if the token's value matches the supplied value, or false otherwise

    - #### matches

          boolean matches(char expected)

      Determine if the token matches the supplied character.
      Parameters:
        `expected` - the expected character value
      Returns:
        true if the token's value matches the supplied character value, or false otherwise

    - #### matches

          boolean matches(int expectedType)

      Determine if the token matches the supplied type.
      Parameters:
        `expectedType` - the expected integer type
      Returns:
        true if the token's value matches the supplied integer type, or false otherwise

    - #### type

          int type()

      Get the type of the token.
      Returns:
        the token's type

    - #### startIndex

          int startIndex()

      Get the index in the raw stream for the first character in the token.
      Returns:
        the starting index of the token

    - #### endIndex

          int endIndex()

      Get the index in the raw stream past the last character in the token.
      Returns:
        the ending index of the token, which is past the last character

    - #### length

          int length()

      Get the length of the token, which is equivalent to `endIndex() - startIndex()`.
      Returns:
        the length

    - #### position

          Position position()

      Get the position of this token, which includes the line number and column number of the first character in the token.
      Returns:
        the position; never null

    - #### withType

          TokenStream.Token withType(int typeMask)

      Bitmask ORed with existing type value.
      Parameters:
        `typeMask` -
      Returns:
        copy of Token with new type

Copyright © 2008-2014 JBoss, a division of Red Hat. All Rights Reserved.