All Downloads are FREE. Search and download functionalities are using the official Maven repository.

gw.lang.reflect.json.Token Maven / Gradle / Ivy

There is a newer version: 1.18.2
Show newest version
package gw.lang.reflect.json;

import java.util.Collections;
import java.util.Map;
import java.util.HashMap;

final class Token {
  private final TokenType type;
  private final String string;
  private final int line;
  private final int column;
  static final Map constants = initializeConstants();

  public Token(TokenType type, String string, int line, int column) {
    this.type = type;
    this.string = string;
    this.line = line;
    this.column = column;
  }

  private static Map initializeConstants() {
    HashMap map = new HashMap();
    map.put("true", TokenType.TRUE);
    map.put("false", TokenType.FALSE);
    map.put("null", TokenType.NULL);
    return Collections.unmodifiableMap(map);
  }

  public String getString() {
    return string;
  }

  public TokenType getType() {
    return type;
  }

  public int getLineNumber() {
    return line;
  }

  public int getColumn() {
    return column;
  }

  @Override
  public String toString() {
    return string + " : " + type;
  }

  public boolean isValueType() {
    return type == TokenType.LCURLY || type == TokenType.LSQUARE ||
           type == TokenType.INTEGER || type == TokenType.DOUBLE ||
           type == TokenType.STRING || type == TokenType.TRUE ||
           type == TokenType.FALSE || type == TokenType.NULL;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy