org.extex.scanner.type.token
Interface Token

All Superinterfaces:
java.io.Serializable
All Known Subinterfaces:
CodeToken
All Known Implementing Classes:
AbstractToken, ActiveCharacterToken, ControlSequenceToken, CrToken, LeftBraceToken, LetterToken, MacroParamToken, MathShiftToken, OtherToken, RightBraceToken, SpaceToken, SubMarkToken, SupMarkToken, TabMarkToken

public interface Token
extends java.io.Serializable

This is the interface for a token. A token is a pair of catcode and value. In most cases the value is a single character. Nevertheless it is also possible to store a complete string in the value – e.g. for control sequence tokens.

Tokens are immutable. Thus no setters for the attributes are provided.

Version:
$Revision: 4738 $
Author:
Gerd Neugebauer, Michael Niedermair

Method Summary
 boolean eq(Catcode cc, char c)
          Compare the current token with a pair of catcode and character value.
 boolean eq(Catcode cc, java.lang.String s)
          Compare the current token with a pair of catcode and String value.
 boolean eq(char c)
          Compare the current token with a character value.
 boolean equals(java.lang.Object t)
          Compare the current token to another token.
 Catcode getCatcode()
          Getter for the catcode.
 UnicodeChar getChar()
          Getter for the value.
 boolean isa(Catcode cc)
          Check if the current token has a specified catcode.
 void toString(java.lang.StringBuffer sb)
          Print the token into a StringBuffer.
 void toString(java.lang.StringBuilder sb)
          Print the token into a StringBuilder.
 java.lang.String toText()
          This method returns the textual representation for the Token.
 java.lang.String toText(UnicodeChar esc)
          Return the printable representation of this token as it can be read back in.
 java.lang.Object visit(TokenVisitor visitor, java.lang.Object arg1)
          Invoke the appropriate visit method for the current class.
 

Method Detail

eq

boolean eq(Catcode cc,
           char c)
Compare the current token with a pair of catcode and character value. This pair constitutes a virtual token. They are the same if the catcode and the value are the same.

Parameters:
cc - the catcode
c - the value
Returns:
true iff the tokens are equal

eq

boolean eq(Catcode cc,
           java.lang.String s)
Compare the current token with a pair of catcode and String value. This pair constitutes a virtual token. They are the same if the catcode and the value are the same.

Parameters:
cc - the catcode
s - the value
Returns:
true iff the tokens are equal

eq

boolean eq(char c)
Compare the current token with a character value. They are the same if the values are the same.

Parameters:
c - the value
Returns:
true iff the tokens are equal

equals

boolean equals(java.lang.Object t)
Compare the current token to another token. They are the same if the catcode and the value are the same.

Overrides:
equals in class java.lang.Object
Parameters:
t - the token to compare to
Returns:
true iff the tokens are equal

getCatcode

Catcode getCatcode()
Getter for the catcode.

Returns:
the catcode

getChar

UnicodeChar getChar()
Getter for the value.

Returns:
the value

isa

boolean isa(Catcode cc)
Check if the current token has a specified catcode.

Parameters:
cc - the catcode to compare against
Returns:
true iff the category codes coincide

toString

void toString(java.lang.StringBuffer sb)
Print the token into a StringBuffer.

Parameters:
sb - the target string buffer

toString

void toString(java.lang.StringBuilder sb)
Print the token into a StringBuilder.

Parameters:
sb - the target string builder

toText

java.lang.String toText()
This method returns the textual representation for the Token. This textual representation might not contain the full information but can be used as an abbreviated form to be shown to the end user. A representation with more complete information can be received with the method toString().

Returns:
the textual representation

toText

java.lang.String toText(UnicodeChar esc)
Return the printable representation of this token as it can be read back in.

Parameters:
esc - the escape character
Returns:
the printable representation

visit

java.lang.Object visit(TokenVisitor visitor,
                       java.lang.Object arg1)
                       throws java.lang.Exception
Invoke the appropriate visit method for the current class.

Parameters:
visitor - the calling visitor
arg1 - the first argument to pass
Returns:
the result object
Throws:
java.lang.Exception - in case of an error