|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--freemarker.template.instruction.IfElseInstruction
A instruction that handles if-elseif-else functionality. The initial
"if" clause is held in a single variable. If any else or elseif clauses
are encountered, they are stored in a List
of
IfInstructions
. The List
is not constructed until
the first else or elseif is encountered.
Fields inherited from interface freemarker.template.instruction.Instruction |
BREAK, CASE, COMMENT_END, COMPRESS_END, DEFAULT, ELSE, ELSEIF, FOREACH_END, FUNCTION_END, IF_END, LIST_END, NONE, NOPARSE_END, SWITCH_END, TRANSFORM_END |
Constructor Summary | |
IfElseInstruction(Expression condition)
Constructs a new if/else instruction without the first block. |
Method Summary | |
void |
addTest(ElseInstruction instruction)
Adds a new test to the if/else instruction. |
TemplateProcessor |
callBuilder(TemplateBuilder builder)
A TemplateBuilder can call
this method to have an Instruction call it back to be built. |
int |
getEndType()
Determine what type of end instruction this is, if any. |
boolean |
isEndInstruction()
Is this an end instruction? |
void |
process(TemplateModelRoot modelRoot,
java.io.Writer out,
TemplateRuntimeHandler eventHandler)
Evaluate the <if ... |
void |
setIfBlock(TemplateProcessor block)
Adds the main block to the first "if" statement. |
java.lang.String |
toString()
Returns a string representation of the object. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public IfElseInstruction(Expression condition)
condition
- the condition for the first ifNullPointerException
- condition is nullMethod Detail |
public void setIfBlock(TemplateProcessor block)
block
- the block to be processed if the first "if" statement
is true
public void addTest(ElseInstruction instruction)
instruction
- the "if" instruction to be evaluated and executedNullPointerException
- instruction is nullpublic boolean isEndInstruction()
isEndInstruction
in interface Instruction
false
, indicating that this is not an end instructionpublic int getEndType()
getEndType
in interface Instruction
NONE
, indicating that this is not an end instructionpublic TemplateProcessor callBuilder(TemplateBuilder builder) throws ParseException
TemplateBuilder
can call
this method to have an Instruction
call it back to be built.
This implementation throws an UnsupportedOperationException
indicating that this is not yet production code.callBuilder
in interface Instruction
builder
- the builder to be called back by this methodpublic void process(TemplateModelRoot modelRoot, java.io.Writer out, TemplateRuntimeHandler eventHandler) throws java.io.IOException
<if ... >
instruction.process
in interface TemplateProcessor
modelRoot
- the root node of the data model.out
- a Writer
to send the output to.eventHandler
- a TemplateEventAdapter
for handling any
events that occur during processing.public java.lang.String toString()
toString
in class java.lang.Object
String
representing this instruction subtree
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |