- All Known Implementing Classes:
- DefaultToken
Token objects can have children, which means they can be in a
    tree structure. For tokens that the LexicalParser.next() method
    returns, tokens of type TokenType.DIRECTIVE only have children.
The Token object has its type, span, and characters. The type is
    one of the constants defined in TokenType, the span represents the
    range of the source file where the token occurs, and the characters are
    SourceChar objects that compose it.
Note that the Token object is an immutable object.
- 
Method SummaryModifier and TypeMethodDescriptiongetChars()Returns the characters that compose this token.Returns the child tokens.getSpan()Returns a new span representing the range of this token in the source file.getType()Returns the type of this token.getValue()Returns a new string representing this token.default booleanTests whether this token has the specified token type.default booleanTests if the characters of this token form the given string.toString()Returns a new string representation of this token that is easy for a person to read.withChildren(Collection<Token> newChildren) Returns a new token that has the same content of this token but has the specified child tokens.Returns a new token that has the same content of this token but has the specified token type.
- 
Method Details- 
getValueString getValue()Returns a new string representing this token.The string that this method returns does not have the clue of the token type and does not include the content of the child tokens. - Returns:
- The new string representing this token.
 
- 
getSpanSourceSpan getSpan()Returns a new span representing the range of this token in the source file.- Returns:
- A new span representing the range of this token.
 
- 
getCharsList<SourceChar> getChars()Returns the characters that compose this token.- Returns:
- The unmodifiable list containing the characters that compose this token.
 
- 
getTypeTokenType getType()Returns the type of this token.- Returns:
- The type of this token.
 
- 
getChildrenReturns the child tokens.This method returns an empty list if this token has no child tokens. - Returns:
- The unmodifiable list containing the child tokens.
 
- 
withTypeReturns a new token that has the same content of this token but has the specified token type.- Parameters:
- newType- The token type of the new token.
- Returns:
- The new token.
 
- 
withChildrenReturns a new token that has the same content of this token but has the specified child tokens.- Parameters:
- newChildren- The child tokens of the new token.
- Returns:
- The new token.
 
- 
toStringString toString()Returns a new string representation of this token that is easy for a person to read.This method returns a string equal to the value of: "[value=" + getValue() + ", span=" + getSpan() + ", " + "chars=" + getChars() + ", type=" + getType() + ", " + "children=" + getChildren() + "]";
- 
isValueTests if the characters of this token form the given string.Returns true if and only if the given string and the return value of getValue()are equal.The comparison is exact (case-sensitive), does not perform any normalization or trimming, and considers only this token's characters (child tokens, if any, are not involved). - Parameters:
- value- the string to compare with the token's characters; must not be null.
- Returns:
- trueif the token's characters equal the given string;- falseotherwise.
 
- 
isTypeTests whether this token has the specified token type.Returns trueif and only if the specifiedtypeis the same enum constant as returned bygetType().- Parameters:
- type- the token type to compare; may be- null
- Returns:
- trueif this token's type equals- type;- falseotherwise
 
 
-