org.extex.unit.base.register.toks
Class ToksParameter

java.lang.Object
  extended by org.extex.interpreter.type.AbstractCode
      extended by org.extex.interpreter.type.AbstractAssignment
          extended by org.extex.unit.base.register.toks.AbstractToks
              extended by org.extex.unit.base.register.toks.ToksParameter
All Implemented Interfaces:
java.io.Serializable, Code, InitializableCode, Theable, TokensConvertible

public class ToksParameter
extends AbstractToks
implements TokensConvertible, Theable, InitializableCode

This class provides an implementation for the primitive \toks. It sets the numbered toks register to the value given, and as a side effect all prefixes are zeroed. Example:

     \toks12{123}
 

Version:
$Revision:4431 $
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
ToksParameter(CodeToken token)
          Creates a new object.
ToksParameter(CodeToken token, java.lang.String key)
          Creates a new object.
 
Method Summary
 void assign(Flags prefix, Context context, TokenSource source, Typesetter typesetter)
          The method assign is the core of the functionality of execute().
 void configure(Configuration config)
          Configure an object according to a given Configuration.
 Tokens convertTokens(Context context, TokenSource source, Typesetter typesetter)
          This method converts a register into tokens.
protected  void expand(Flags prefix, Context context, TokenSource source, Typesetter typesetter, java.lang.String key)
          Scan the tokens between { and } and store them in the named tokens register.
protected  java.lang.String getKey(Context context, TokenSource source, Typesetter typesetter)
          Return the key (the name of the primitive) for the numbered tokens register.
static java.lang.String getKey(java.lang.String name, Context context)
          Return the key for a named toks register.
 void init(Context context, TokenSource source, Typesetter typesetter)
          Initialize the Code with some value coming from a String.
 Tokens the(Context context, TokenSource source, Typesetter typesetter)
          Return the register value as Tokens for \the.
 
Methods inherited from class org.extex.interpreter.type.AbstractAssignment
execute
 
Methods inherited from class org.extex.interpreter.type.AbstractCode
getLocalizer, getName, getToken, isIf, isOuter, readResolve, toString, toText, toText
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

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

See Also:
Constant Field Values
Constructor Detail

ToksParameter

public ToksParameter(CodeToken token)
Creates a new object.

Parameters:
token - the initial token for the primitive

ToksParameter

public ToksParameter(CodeToken token,
                     java.lang.String key)
Creates a new object.

Parameters:
token - the initial token for the primitive
key - the key
Method Detail

getKey

public static java.lang.String getKey(java.lang.String name,
                                      Context context)
Return the key for a named toks register.

Parameters:
name - the name of the register
context - the interpreter context to use
Returns:
the key for the toks register

configure

public void configure(Configuration config)
Configure an object according to a given Configuration.

Parameters:
config - the configuration object to consider
See Also:
org.extex.framework.configuration.Configurable#configure( org.extex.framework.configuration.Configuration)

getKey

protected java.lang.String getKey(Context context,
                                  TokenSource source,
                                  Typesetter typesetter)
                           throws TypesetterException
Return the key (the name of the primitive) for the numbered tokens register.

Overrides:
getKey in class AbstractToks
Parameters:
context - the interpreter context to use
source - the source for new tokens
typesetter - the typesetter
Returns:
the key for the current register
Throws:
TypesetterException - in case of an error in the typesetter
See Also:
AbstractToks.getKey( org.extex.interpreter.context.Context, org.extex.interpreter.TokenSource, org.extex.typesetter.Typesetter)

init

public void init(Context context,
                 TokenSource source,
                 Typesetter typesetter)
          throws HelpingException,
                 TypesetterException
Initialize the Code with some value coming from a String.

Specified by:
init in interface InitializableCode
Parameters:
context - the interpreter context
source - the source of information for the initialization
typesetter - the typesetter
Throws:
HelpingException - in case of an error
TypesetterException - in case of an error in the typesetter
See Also:
InitializableCode.init( org.extex.interpreter.context.Context, TokenSource, Typesetter)

assign

public void assign(Flags prefix,
                   Context context,
                   TokenSource source,
                   Typesetter typesetter)
            throws HelpingException,
                   TypesetterException
The method assign is the core of the functionality of execute(). This method is preferable to execute() since the execute() method provided in this class takes care of \afterassignment and \globaldefs as well.

Specified by:
assign in class AbstractAssignment
Parameters:
prefix - the prefix controlling the execution
context - the interpreter context
source - the token source
typesetter - the typesetter
Throws:
HelpingException - in case of an error
TypesetterException - in case of an error in the typesetter
See Also:
AbstractAssignment.assign( org.extex.interpreter.Flags, org.extex.interpreter.context.Context, org.extex.interpreter.TokenSource, org.extex.typesetter.Typesetter)

convertTokens

public Tokens convertTokens(Context context,
                            TokenSource source,
                            Typesetter typesetter)
                     throws HelpingException,
                            TypesetterException
This method converts a register into tokens. It might be necessary to read further tokens to determine which value to use. For instance an additional register number might be required. In this case the additional arguments Context and TokenSource can be used.

Specified by:
convertTokens in interface TokensConvertible
Parameters:
context - the interpreter context
source - the source for new tokens
typesetter - the typesetter to use for conversion
Returns:
the converted value
Throws:
HelpingException - in case of an error
TypesetterException - in case of an error in the typesetter
See Also:
TokensConvertible.convertTokens( org.extex.interpreter.context.Context, org.extex.interpreter.TokenSource, org.extex.typesetter.Typesetter)

expand

protected void expand(Flags prefix,
                      Context context,
                      TokenSource source,
                      Typesetter typesetter,
                      java.lang.String key)
               throws GeneralException
Scan the tokens between { and } and store them in the named tokens register.

Parameters:
prefix - the prefix flags
context - the interpreter context
source - the token source
typesetter - the typesetter
key - the key
Throws:
GeneralException - in case of an error

the

public Tokens the(Context context,
                  TokenSource source,
                  Typesetter typesetter)
           throws HelpingException,
                  TypesetterException
Return the register value as Tokens for \the.

Specified by:
the in interface Theable
Parameters:
context - the interpreter context
source - the source for further tokens to qualify the request
typesetter - the typesetter to use
Returns:
the description of the primitive as list of Tokens
Throws:
HelpingException - in case of an error
TypesetterException - in case of an error
See Also:
Theable.the( org.extex.interpreter.context.Context, org.extex.interpreter.TokenSource, Typesetter)