org.extex.scanner.type.token
Class ControlSequenceToken

java.lang.Object
  extended by org.extex.scanner.type.token.AbstractToken
      extended by org.extex.scanner.type.token.ControlSequenceToken
All Implemented Interfaces:
java.io.Serializable, CodeToken, Token

public class ControlSequenceToken
extends AbstractToken
implements CodeToken

This class represents a control sequence token.

This class has a protected constructor only. Use the factory TokenFactory to get an instance of this class.

Note that in contrast to TeX the escape character leading to this control sequence token is stored in the character code of the abstract base class.

Version:
$Revision:4399 $
Author:
Gerd Neugebauer
See Also:
Serialized Form

Field Summary
protected static long serialVersionUID
          The constant serialVersionUID contains the id for serialization.
 
Constructor Summary
protected ControlSequenceToken(UnicodeChar esc, java.lang.String name, java.lang.String namespace)
          Creates a new object from the first character of a String.
 
Method Summary
 CodeToken cloneInDefaultNamespace()
          Create a new instance of the token where the name space is the default name space and the other attributes are the same as for the current token.
 CodeToken cloneInNamespace(java.lang.String theNamespace)
          Create a new instance of the token where the name space is the given one and the other attributes are the same as for the current token.
 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 other)
          Indicates whether some other object is "equal to" this one.
 Catcode getCatcode()
          Getter for the catcode.
 java.lang.String getName()
          Getter for the name.
 java.lang.String getNamespace()
          Getter for the name space.
 int hashCode()
          Returns a hash code value for the object.
 java.lang.String toString()
          Get the string representation of this object for debugging purposes.
 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()
          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.
 java.lang.Object visit(TokenVisitor visitor, java.lang.Object arg1)
          Invoke the appropriate visit method for the current class.
 
Methods inherited from class org.extex.scanner.type.token.AbstractToken
getChar, getLocalizer, isa
 
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
getChar, isa
 

Field Detail

serialVersionUID

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

See Also:
Constant Field Values
Constructor Detail

ControlSequenceToken

protected ControlSequenceToken(UnicodeChar esc,
                               java.lang.String name,
                               java.lang.String namespace)
Creates a new object from the first character of a String. If the string is empty then a space character is used instead.

Parameters:
esc - the escape character
name - the name of the control sequence – without the leading escape character token
namespace - the name space
Method Detail

cloneInDefaultNamespace

public CodeToken cloneInDefaultNamespace()
Create a new instance of the token where the name space is the default name space and the other attributes are the same as for the current token.

Specified by:
cloneInDefaultNamespace in interface CodeToken
Returns:
the new token
See Also:
CodeToken.cloneInDefaultNamespace()

cloneInNamespace

public CodeToken cloneInNamespace(java.lang.String theNamespace)
Create a new instance of the token where the name space is the given one and the other attributes are the same as for the current token.

Specified by:
cloneInNamespace in interface CodeToken
Parameters:
theNamespace - the name space to use
Returns:
the new token
See Also:
CodeToken.cloneInNamespace( java.lang.String)

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
Overrides:
eq in class AbstractToken
Parameters:
cc - the catcode
c - the value
Returns:
true iff the tokens are equal
See Also:
AbstractToken.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
Overrides:
eq in class AbstractToken
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
Overrides:
eq in class AbstractToken
Parameters:
c - the value
Returns:
true iff the tokens are equal
See Also:
AbstractToken.eq(char)

equals

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

Specified by:
equals in interface Token
Overrides:
equals in class AbstractToken
Parameters:
other - the reference object 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 Catcode getCatcode()
Getter for the catcode.

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

getName

public java.lang.String getName()
Getter for the name. The name is the string representation without the escape character in front.

Specified by:
getName in interface CodeToken
Returns:
the name of the token
See Also:
CodeToken.getName()

getNamespace

public java.lang.String getNamespace()
Getter for the name space.

Specified by:
getNamespace in interface CodeToken
Returns:
the name space
See Also:
CodeToken.getNamespace()

hashCode

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

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

toString

public java.lang.String toString()
Get the string representation of this object for debugging purposes.

Overrides:
toString in class AbstractToken
Returns:
the string representation

toString

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

Specified by:
toString in interface Token
Parameters:
sb - the target string buffer
See Also:
Token.toString(java.lang.StringBuffer)

toString

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

Specified by:
toString in interface Token
Parameters:
sb - the target string builder
See Also:
Token.toString(java.lang.StringBuilder)

toText

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

Specified by:
toText in interface Token
Overrides:
toText in class AbstractToken
Returns:
the text representation
See Also:
AbstractToken.toText()

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
Overrides:
toText in class AbstractToken
Parameters:
esc - the escape character
Returns:
the printable representation
See Also:
Token.toText( org.extex.core.UnicodeChar)

visit

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

Specified by:
visit in interface Token
Parameters:
visitor - the calling visitor
arg1 - the first argument to pass
Returns:
the result object
Throws:
java.lang.Exception - in case of an error
See Also:
Token.visit( org.extex.scanner.type.token.TokenVisitor, java.lang.Object)