org.extex.interpreter.type
Class AbstractCode

java.lang.Object
  extended by org.extex.interpreter.type.AbstractCode
All Implemented Interfaces:
java.io.Serializable, Code
Direct Known Subclasses:
AbstractAlign, AbstractAssignment, AbstractBoxPrimitive, AbstractDirCode, AbstractFileCode, AbstractHorizontalCode, AbstractHyphenationCode, AbstractIf, AbstractMarkCode, AbstractMarksCode, AbstractMath, AbstractMathCode, AbstractModeCode, AbstractOcplist, AbstractPdftexCode, AbstractReadonlyCount, AbstractVerticalCode, Accent, Afterassignment, Aftergroup, Badness, Begingroup, BeginL, BeginR, BoxParameter, BoxPrimitive, Char, CharCode, Closein, Closeout, Copy, Cr, Csname, Currentgrouplevel, Currentgrouptype, Currentifbranch, Currentiflevel, Currentiftype, Detokenize, Dimenexpr, Discretionary, Dump, Efcode, Else, End, Endcsname, Endgroup, Endinput, EndL, EndR, EnsureLoaded, Errmessage, Expandafter, Fi, Fontchardp, Fontcharht, Fontcharic, Fontcharwd, FontCode, Fontname, Global, Glueexpr, Glueshrink, Glueshrinkorder, Gluestretch, Gluestretchorder, Gluetomu, Hrule, Hyphen, Ignorespaces, Immediate, Indent, Inputlineno, Insert, ItalicCorrection, JavaLoad, Jobname, Kern, Lastbox, Lastkern, Lastpenalty, Leaders, LetCode, Localleftbox, Localrightbox, Long, Lowercase, MacroCode, Message, Muexpr, Mutoglue, NativeLoad, Naturaldir, Noalign, Noboundary, Noexpand, Noindent, NullfontPrimitive, Nullocplist, Number, Numexpr, OcpList, Oglueshrinkorder, Ogluestretchorder, Omit, Or, Outer, OutputTranslation, Par, Parshape, Parshapedimen, Parshapeindent, Parshapelength, Penalty, Popocplist, PrintFormat, Protected, Pushocplist, Relax, Romannumeral, Scantokens, Setlanguage, Shipout, Show, Showbox, Showgroups, Showlists, Showprefix, Showthe, Showtokens, Space, Spacefactor, Span, Special, StringPrimitive, The, Unexpanded, Unhbox, Unhcopy, Unkern, Unless, Unnaturaldir, Unpenalty, Unskip, Unvbox, Unvcopy, Uppercase, Vadjust, Vrule, Vsplit, Write, WriterType

public abstract class AbstractCode
extends java.lang.Object
implements Code, java.io.Serializable

This is the abstract base class which can be used for all classes implementing the interface Code. It provides some useful definitions for most of the methods.

Version:
$Revision: 6802 $
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
AbstractCode(CodeToken token)
          Creates a new object.
 
Method Summary
 void execute(Flags prefix, Context context, TokenSource source, Typesetter typesetter)
          This method takes the first token and executes it.
protected  Localizer getLocalizer()
          Getter for localizer.
 java.lang.String getName()
          Getter for the name.
 CodeToken getToken()
          Getter for token.
 boolean isIf()
          This simple little method distinguishes the conditionals from the other primitives.
 boolean isOuter()
          Getter for the outer flag.
protected  java.lang.Object readResolve()
          Restore the internal state when the instance is loaded from file.
 java.lang.String toString()
           
 java.lang.String toText()
          Determine the printable representation of the control sequence or active character initially bound to the primitive.
 java.lang.String toText(Context context)
          Determine the printable representation of the control sequence or active character initially bound to the primitive.
 
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

AbstractCode

public AbstractCode(CodeToken token)
Creates a new object.

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

execute

public void execute(Flags prefix,
                    Context context,
                    TokenSource source,
                    Typesetter typesetter)
             throws HelpingException,
                    TypesetterException
This method takes the first token and executes it. The result is placed on the stack. This operation might have side effects. To execute a token it might be necessary to consume further tokens.

Specified by:
execute in interface Code
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:
Code.execute( org.extex.interpreter.Flags, org.extex.interpreter.context.Context, org.extex.interpreter.TokenSource, org.extex.typesetter.Typesetter)

getLocalizer

protected Localizer getLocalizer()
Getter for localizer.

Returns:
the localizer.

getName

public java.lang.String getName()
Description copied from interface: Code
Getter for the name.

Specified by:
getName in interface Code
Returns:
the name
See Also:
Code.getName()

getToken

public CodeToken getToken()
Getter for token.

Specified by:
getToken in interface Code
Returns:
the token

isIf

public boolean isIf()
Description copied from interface: Code
This simple little method distinguishes the conditionals from the other primitives. This is necessary for the processing of all \if* primitives.

Specified by:
isIf in interface Code
Returns:
true iff this is some sort if \if.
See Also:
Code.isIf()

isOuter

public boolean isOuter()
Description copied from interface: Code
Getter for the outer flag.

Specified by:
isOuter in interface Code
Returns:
true iff the code is defined outer.
See Also:
Code.isOuter()

readResolve

protected java.lang.Object readResolve()
                                throws java.io.ObjectStreamException
Restore the internal state when the instance is loaded from file.

Returns:
the object which should be used instead of the one read
Throws:
java.io.ObjectStreamException - in case of an error

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
See Also:
Object.toString()

toText

public java.lang.String toText()
Determine the printable representation of the control sequence or active character initially bound to the primitive. For the control sequence attach the escape character in front of the name and return the result. Otherwise just use the character.

If the token is not known then the empty string is returned.

Returns:
the control sequence including the escape character, the active character or the empty string

toText

public java.lang.String toText(Context context)
Determine the printable representation of the control sequence or active character initially bound to the primitive. For the control sequence attach the current escape character from the context in front of the name and return the result. Otherwise just use the character.

If the token is not known then the empty string is returned.

Parameters:
context - the processing context
Returns:
the control sequence including the escape character, the active character or the empty string