|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.extex.interpreter.type.AbstractCode
org.extex.unit.base.conditional.AbstractIf
org.extex.unit.tex.conditional.Ifcase
public class Ifcase
This class provides an implementation for the primitive
The primitive \ifcase provides a conditional switch on a numeric
value. The next tokens are used as a number. This number determines which
branch to expand. The first branch follows the number immediately. This
branch is associated to the number 0.
The primitive \or advances to the next branch. The primitive
\else starts the else branch. The else branch is used if no other
branch fits.
\ifcase.
The Primitive \ifcase
Syntax
The formal description of this primitive is the following:
〈ifcase〉
→ \ifcase 〈number〉 〈cases〉 \fi
〈cases〉
→
| 〈branch text〉 \else 〈else text〉
| 〈branch text〉 \or 〈cases〉
Examples
\ifcase\count0 a\or b\or c\else x\fi
| Nested Class Summary | |
|---|---|
protected static class |
Ifcase.Tag
This is an internal class for type-safe values. |
| Field Summary | |
|---|---|
protected static Ifcase.Tag |
ELSE
The constant ELSE contains the value indicating an \else. |
protected static Ifcase.Tag |
FI
The constant FI contains the value indicating a \fi. |
protected static Ifcase.Tag |
OR
The constant OR contains the value indicating an \or. |
protected static long |
serialVersionUID
The constant serialVersionUID contains the id for serialization. |
| Constructor Summary | |
|---|---|
Ifcase(CodeToken token)
Creates a new object. |
|
| Method Summary | |
|---|---|
boolean |
conditional(Context context,
TokenSource source,
Typesetter typesetter)
This method computes the boolean value of the conditional. |
void |
execute(Flags prefix,
Context context,
TokenSource source,
Typesetter typesetter)
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. |
void |
expand(Flags prefix,
Context context,
TokenSource source,
Typesetter typesetter)
This method takes the first token and expands it. The result is placed on the stack. This means that expandable code does one step of expansion and puts the result on the stack. To expand a token it might be necessary to consume further tokens. |
| Methods inherited from class org.extex.unit.base.conditional.AbstractIf |
|---|
getMyLocalizer, isIf, skipToElseOrFi |
| Methods inherited from class org.extex.interpreter.type.AbstractCode |
|---|
getLocalizer, getName, getToken, isOuter, readResolve, toString, toText, toText |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected static final long serialVersionUID
protected static final Ifcase.Tag OR
protected static final Ifcase.Tag ELSE
protected static final Ifcase.Tag FI
| Constructor Detail |
|---|
public Ifcase(CodeToken token)
token - the initial token for the primitive| Method Detail |
|---|
public void execute(Flags prefix,
Context context,
TokenSource source,
Typesetter typesetter)
throws HelpingException,
TypesetterException
execute in interface Codeexecute in class AbstractIfprefix - the prefix controlling the executioncontext - the interpreter contextsource - the token sourcetypesetter - the typesetter
HelpingException - in case of an error
TypesetterException - in case of an error in the typesetterAbstractIf.execute(
org.extex.interpreter.Flags, org.extex.interpreter.context.Context,
org.extex.interpreter.TokenSource, org.extex.typesetter.Typesetter)
public void expand(Flags prefix,
Context context,
TokenSource source,
Typesetter typesetter)
throws HelpingException,
TypesetterException
expand in interface ExpandableCodeexpand in class AbstractIfprefix - the prefix flags controlling the expansioncontext - the interpreter contextsource - the token sourcetypesetter - the typesetter
HelpingException - in case of an error
TypesetterException - in case of an error in the typesetterAbstractIf.expand(
org.extex.interpreter.Flags, org.extex.interpreter.context.Context,
org.extex.interpreter.TokenSource, org.extex.typesetter.Typesetter)
public boolean conditional(Context context,
TokenSource source,
Typesetter typesetter)
throws HelpingException
true then the then branch is expanded and the else
branch is skipped. Otherwise the then branch is skipped and the else
branch is expanded.
conditional in class AbstractIfcontext - the interpreter contextsource - the source for new tokenstypesetter - the typesetter
HelpingException - in case of an errorAbstractIf.conditional(
org.extex.interpreter.context.Context,
org.extex.interpreter.TokenSource, org.extex.typesetter.Typesetter)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||