Package org.codehaus.janino

# Class Token

java.lang.Object
org.codehaus.janino.Token

public final class Token extends Object
Immutable representation of a Java token.

## Field Summary

Fields
Modifier and Type
Field
Description
`final TokenType`
`type`
The type of this token.
`final String`
`value`
The text of the token exactly as it appears in the source code.

## Constructor Summary

Constructors
Constructor
Description
`Token(String fileName, int lineNumber, int columnNumber, TokenType type, String value)`
`Token(Location location, TokenType type, String value)`

## Method Summary

Modifier and Type
Method
Description
`Location`
`getLocation()`
`String`
`toString()`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

## Field Details

### type

public final TokenType type
The type of this token.

Strictly speaking, this field is redundant, because the token type can always be deduced from the token value, e.g. iff the value begins with "'", then the type is `TokenType.CHARACTER_LITERAL`.

### value

public final String value
The text of the token exactly as it appears in the source code.

Iff this token represents a keyword, `true`, `false`, `null` or an operator, then this string is `interned`, so that it can be reference-compared with other interned strings.

## Constructor Details

### Token

public Token(@Nullable String fileName, int lineNumber, int columnNumber, TokenType type, String value)

### Token

public Token(Location location, TokenType type, String value)

## Method Details

### getLocation

public Location getLocation()

Returns:
  The location of the first character of this token

### toString

public String toString()

Overrides:
  `toString` in class `Object`