GQLToken.java

  1. package net.morimekta.providence.graphql.parser;

  2. import net.morimekta.util.lexer.Token;

  3. import javax.annotation.Nonnull;

  4. public class GQLToken extends Token<GQLTokenType> {
  5.     // Various symbols.
  6.     public static final char kMessageStart  = '{';
  7.     public static final char kMessageEnd    = '}';
  8.     public static final char kKeyValueSep   = ':';
  9.     public static final char kFieldValueSep = '=';
  10.     public static final char kParamsStart   = '(';
  11.     public static final char kParamsEnd     = ')';
  12.     public static final char kListStart     = '[';
  13.     public static final char kListEnd       = ']';
  14.     public static final char kEntrySep      = ',';

  15.     public static final char kDirective     = '@';
  16.     public static final char kVariable      = '$';

  17.     /**
  18.      * Create a slice instance. The slice is only meant to be internal state
  19.      * immutable, and not representing an immutable byte content.
  20.      *
  21.      * @param fb      The buffer to wrap.
  22.      * @param off     The start offset to wrap.
  23.      * @param len     The length to represent.
  24.      * @param type    The token type represented.
  25.      * @param lineNo  The current line number.
  26.      * @param linePos The current line position.
  27.      */
  28.     public GQLToken(char[] fb,
  29.                     int off,
  30.                     int len,
  31.                     @Nonnull GQLTokenType type, int lineNo, int linePos) {
  32.         super(fb, off, len, type, lineNo, linePos);
  33.     }

  34.     public boolean isString() {
  35.         return type == GQLTokenType.STRING;
  36.     }

  37.     public boolean isIdentifier() {
  38.         return type == GQLTokenType.IDENTIFIER;
  39.     }

  40.     public boolean isVariable() {
  41.         return type == GQLTokenType.VARIABLE;
  42.     }

  43.     public boolean isDirectve() {
  44.         return type == GQLTokenType.DIRECTIVE;
  45.     }
  46. }