org.extex.scanner.type.token
Class AbstractToken

java.lang.Object
  extended by org.extex.scanner.type.token.AbstractToken
All Implemented Interfaces:
java.io.Serializable, Token
Direct Known Subclasses:
ActiveCharacterToken, ControlSequenceToken, CrToken, LeftBraceToken, LetterToken, MacroParamToken, MathShiftToken, OtherToken, RightBraceToken, SpaceToken, SubMarkToken, SupMarkToken, TabMarkToken

public abstract class AbstractToken
extends java.lang.Object
implements Token, java.io.Serializable

This is the abstract base class for all Tokens.

Version:
$Revision: 4738 $
Author:
Gerd Neugebauer, Michael Niedermair
See Also:
Serialized Form

Field Summary
protected static long serialVersionUID
          The constant serialVersionUID contains the id for serialization.
 
Constructor Summary
protected AbstractToken(UnicodeChar uc)
          Creates a new object for a Unicode character.
 
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)
          Indicates whether some other object is "equal to" this one.
abstract  Catcode getCatcode()
          Getter for the catcode.
 UnicodeChar getChar()
          Getter for the value.
protected  Localizer getLocalizer()
          Getter for localizer.
 int hashCode()
          Returns a hash code value for the object.
 boolean isa(Catcode cc)
          Check if the current token has a specified catcode.
 java.lang.String toString()
          Return the printable representation of this object.
 java.lang.String toText()
          Return the text representation of this object.
 java.lang.String toText(UnicodeChar esc)
          Return the printable representation of this token as it can be read back in.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.extex.scanner.type.token.Token
toString, toString, visit
 

Field Detail

serialVersionUID

protected static final long serialVersionUID
The constant serialVersionUID contains the id for serialization.

See Also:
Constant Field Values
Constructor Detail

AbstractToken

protected AbstractToken(UnicodeChar uc)
Creates a new object for a Unicode character.

Parameters:
uc - the value of the token
Method Detail

eq

public 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.

Specified by:
eq in interface Token
Parameters:
cc - the catcode
c - the value
Returns:
true iff the tokens are equal
See Also:
Token.eq( org.extex.scanner.type.Catcode, char)

eq

public 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.

Specified by:
eq in interface Token
Parameters:
cc - the catcode
s - the value
Returns:
true iff the tokens are equal
See Also:
Token.eq( org.extex.scanner.type.Catcode, java.lang.String)

eq

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

Specified by:
eq in interface Token
Parameters:
c - the value
Returns:
true iff the tokens are equal
See Also:
Token.eq(char)

equals

public boolean equals(java.lang.Object t)
Indicates whether some other object is "equal to" this one.

Specified by:
equals in interface Token
Overrides:
equals in class java.lang.Object
Parameters:
t - the reference token with which to compare.
Returns:
true if this object is the same as the obj argument; false otherwise.
See Also:
Object.equals(java.lang.Object)

getCatcode

public abstract Catcode getCatcode()
Getter for the catcode.

Specified by:
getCatcode in interface Token
Returns:
the catcode
See Also:
Token.getCatcode()

getChar

public final UnicodeChar getChar()
Getter for the value.

Specified by:
getChar in interface Token
Returns:
the value
See Also:
Token.getChar()

getLocalizer

protected Localizer getLocalizer()
Getter for localizer.

Returns:
the localizer.

hashCode

public int hashCode()
Returns a hash code value for the object.

Overrides:
hashCode in class java.lang.Object
Returns:
a hash code value for this object
See Also:
Object.hashCode()

isa

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

Specified by:
isa in interface Token
Parameters:
cc - the catcode to compare against
Returns:
true iff the catcodes coincide
See Also:
Token.isa( org.extex.scanner.type.Catcode)

toString

public java.lang.String toString()
Return the printable representation of this object.

Overrides:
toString in class java.lang.Object
Returns:
the printable representation

toText

public java.lang.String toText()
Return the text representation of this object.

Specified by:
toText in interface Token
Returns:
the text representation

toText

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

Specified by:
toText in interface Token
Parameters:
esc - the escape character
Returns:
the printable representation
See Also:
Token.toText( org.extex.core.UnicodeChar)