org.extex.scanner.type.token
Interface TokenFactory

All Known Implementing Classes:
TokenFactoryImpl

public interface TokenFactory

This is the interface for the token factory. The token factory is the only instance to deliver new tokens. It is up to the implementation of the factory to create new tokens or to cache some of them and deliver the same token several times.

Version:
$Revision: 4738 $
Author:
Gerd Neugebauer

Method Summary
 Token createToken(Catcode code, int c, java.lang.String namespace)
          Create a new Token of the appropriate kind.
 Token createToken(Catcode code, UnicodeChar c, java.lang.String namespace)
          Get an instance of a token with a given Catcode and Unicode character value.
 Token createToken(Catcode code, UnicodeChar esc, java.lang.String value, java.lang.String namespace)
          Get an instance of a token with a given Catcode and value.
 Tokens toTokens(java.lang.CharSequence s)
          Convert a character sequence to a list of tokens.
 Tokens toTokens(long l)
          Convert a long value into a list of tokens.
 

Method Detail

createToken

Token createToken(Catcode code,
                  UnicodeChar esc,
                  java.lang.String value,
                  java.lang.String namespace)
                  throws CatcodeException
Get an instance of a token with a given Catcode and value.

Parameters:
code - the catcode
esc - the Unicode character value of the escape character
value - the value
namespace - the name space for the token. This is relevant for ACTIVE and ESCAPE category codes only.
Returns:
the appropriate token
Throws:
CatcodeException - in case of an error

createToken

Token createToken(Catcode code,
                  int c,
                  java.lang.String namespace)
                  throws CatcodeException
Create a new Token of the appropriate kind. Tokens are immutable (no setters) thus the factory pattern can be applied.

Parameters:
code - the category code
c - the character value
namespace - the name space to use
Returns:
the new token
Throws:
CatcodeException - in case of an error

createToken

Token createToken(Catcode code,
                  UnicodeChar c,
                  java.lang.String namespace)
                  throws CatcodeException
Get an instance of a token with a given Catcode and Unicode character value.

Parameters:
code - the catcode
c - the Unicode character value
namespace - the name space for the token. This is relevant for ACTIVE and ESCAPE category codes only.
Returns:
the appropriate token
Throws:
CatcodeException - in case of an error

toTokens

Tokens toTokens(java.lang.CharSequence s)
                throws CatcodeException
Convert a character sequence to a list of tokens.

Each character of the string is converted into a OtherToken and added to the internal list. An exception is made for spaces which are converted into a SpaceToken.

Parameters:
s - the character sequence to translate to tokens
Returns:
the token list
Throws:
CatcodeException - in case of an error

toTokens

Tokens toTokens(long l)
                throws CatcodeException
Convert a long value into a list of tokens.

Each character is converted into a OtherToken and added to the internal list.

Parameters:
l - the value to convert
Returns:
the token list
Throws:
CatcodeException - in case of an error