org.extex.interpreter.primitives.register.real
Class NamedReal

java.lang.Object
  extended by org.extex.interpreter.type.AbstractCode
      extended by org.extex.interpreter.type.AbstractAssignment
          extended by org.extex.interpreter.primitives.register.real.NamedReal
All Implemented Interfaces:
java.io.Serializable, CountConvertible, RealConvertible, Code, Advanceable, Divideable, Multiplyable, Theable
Direct Known Subclasses:
NumberedReal

public class NamedReal
extends AbstractAssignment
implements Theable, Advanceable, Multiplyable, Divideable, RealConvertible, CountConvertible

This class provides an implementation for the real valued primitives. It sets the named real register to the value given, and as a side effect all prefixes are zeroed.

Example

 \pi=3.1415
 

Version:
$Revision: 6447 $
Author:
Michael Niedermair
See Also:
Serialized Form

Constructor Summary
NamedReal(CodeToken token, java.lang.String key)
          Creates a new object.
 
Method Summary
 void advance(Flags prefix, Context context, TokenSource source, Typesetter typesetter)
          This method is called when the macro \advance has been seen.
 void assign(Flags prefix, Context context, TokenSource source, Typesetter typesetter)
          The method assign is the core of the functionality of execute().
 long convertCount(Context context, TokenSource source, Typesetter typesetter)
          This method converts a register into a count.
 Real convertReal(Context context, TokenSource source, Typesetter typesetter)
          Convert to a real.
 void divide(Flags prefix, Context context, TokenSource source, Typesetter typesetter)
          This method is called when the macro \divide has been seen.
protected  java.lang.String getKey(Context context, TokenSource source, Typesetter typesetter)
          Return the key (the name of the primitive) for the register.
 void multiply(Flags prefix, Context context, TokenSource source, Typesetter typesetter)
          This method is called when the macro \multiply has been seen.
 void set(Context context, Real value)
          set the value
 void set(Context context, java.lang.String value)
          Set the value
 Tokens the(Context context, TokenSource source, Typesetter typesetter)
          This method is the getter for the description of the primitive.
 
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
 

Constructor Detail

NamedReal

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

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

assign

public void assign(Flags prefix,
                   Context context,
                   TokenSource source,
                   Typesetter typesetter)
            throws ConfigurationException,
                   HelpingException,
                   TypesetterException
Description copied from class: AbstractAssignment
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:
ConfigurationException - in case of an configuration error
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)

set

public void set(Context context,
                Real value)
         throws HelpingException
set the value

Parameters:
context - the interpreter context
value - the new value as Real
Throws:
HelpingException - if no extension is configured

set

public void set(Context context,
                java.lang.String value)
         throws HelpingException
Set the value

Parameters:
context - the interpreter context
value - the new value as String
Throws:
HelpingException - if no extension is configured

the

public Tokens the(Context context,
                  TokenSource source,
                  Typesetter typesetter)
           throws CatcodeException,
                  HelpingException,
                  TypesetterException
This method is the getter for the description of the primitive.

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:
CatcodeException - in case of an error in token creation
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, org.extex.typesetter.Typesetter)

getKey

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

Parameters:
context - the context
source - the token source
typesetter - the typesetter
Returns:
the key
Throws:
HelpingException - in case of an error.
TypesetterException - in case of an error in the typesetter

advance

public void advance(Flags prefix,
                    Context context,
                    TokenSource source,
                    Typesetter typesetter)
             throws ConfigurationException,
                    HelpingException,
                    TypesetterException
Description copied from interface: Advanceable
This method is called when the macro \advance has been seen. It performs the remaining tasks for the expansion.

Specified by:
advance in interface Advanceable
Parameters:
prefix - the prefix for the command
context - the processor context
source - the token source to parse
typesetter - the typesetter
Throws:
ConfigurationException - in case of an configuration error
HelpingException - in case of an error
TypesetterException - in case of an error in the typesetter
See Also:
Advanceable.advance( org.extex.interpreter.Flags, org.extex.interpreter.context.Context, org.extex.interpreter.TokenSource, org.extex.typesetter.Typesetter)

multiply

public void multiply(Flags prefix,
                     Context context,
                     TokenSource source,
                     Typesetter typesetter)
              throws HelpingException,
                     TypesetterException
This method is called when the macro \multiply has been seen. It performs the remaining tasks for the expansion.

Specified by:
multiply in interface Multiplyable
Parameters:
prefix - the prefix for the command
context - the processor context
source - the token source to parse
typesetter - the typesetter
Throws:
HelpingException - in case of an error
TypesetterException - in case of an error in the typesetter
See Also:
Multiplyable.multiply(org.extex.interpreter.Flags, org.extex.interpreter.context.Context, org.extex.interpreter.TokenSource, org.extex.typesetter.Typesetter)

divide

public void divide(Flags prefix,
                   Context context,
                   TokenSource source,
                   Typesetter typesetter)
            throws HelpingException,
                   TypesetterException
This method is called when the macro \divide has been seen. It performs the remaining tasks for the expansion.

Specified by:
divide in interface Divideable
Parameters:
prefix - the prefix for the command
context - the processor context
source - the token source to parse
typesetter - the typesetter
Throws:
HelpingException - in case of an error
TypesetterException - in case of an error in the typesetter
See Also:
Divideable.divide(org.extex.interpreter.Flags, org.extex.interpreter.context.Context, org.extex.interpreter.TokenSource, org.extex.typesetter.Typesetter)

convertReal

public Real convertReal(Context context,
                        TokenSource source,
                        Typesetter typesetter)
                 throws HelpingException,
                        TypesetterException
Description copied from interface: RealConvertible
Convert to a real.

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

convertCount

public long convertCount(Context context,
                         TokenSource source,
                         Typesetter typesetter)
                  throws HelpingException,
                         TypesetterException
This method converts a register into a count. 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:
convertCount in interface CountConvertible
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:
CountConvertible.convertCount(org.extex.interpreter.context.Context, org.extex.interpreter.TokenSource, org.extex.typesetter.Typesetter)