freemarker.template.instruction
Class ListInstruction
java.lang.Object
freemarker.template.instruction.GenericStartInstruction
freemarker.template.instruction.ListInstruction
- All Implemented Interfaces:
- ContainerInstruction, Instruction, TemplateProcessor, java.io.Serializable
public final class ListInstruction
- extends GenericStartInstruction
An instruction that processes a TemplateListModel
or TemplateListModel2. This can be either in the
form of a <list ... as ...> instruction or a
<foreach ... in ...> instruction.
- See Also:
- Serialized Form
| Fields inherited from interface freemarker.template.instruction.Instruction |
ASSIGN_END, 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 |
ListInstruction(Expression listExpression,
Identifier indexVariable)
Constructs a list/foreach instruction containing the list variable and
the index variable. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
ListInstruction
public ListInstruction(Expression listExpression,
Identifier indexVariable)
- Constructs a list/foreach instruction containing the list variable and
the index variable.
- Parameters:
listExpression - a variable or list expression referring to a
TemplateListModel.indexVariable - an arbitrary index variable.
- Throws:
java.lang.NullPointerException - list expression or index variable are null
java.lang.IllegalArgumentException - the list expression wasn't a list
testEndInstruction
public boolean testEndInstruction(Instruction endInstruction)
- Is this the right kind of instruction for the given
EndInstruction?
- Parameters:
endInstruction - the end instruction we're testing
- Returns:
true if the EndInstruction is a list
end instruction, otherwise false
callBuilder
public TemplateProcessor callBuilder(TemplateBuilder builder)
throws ParseException
- Call the
TemplateBuilder with this
list instruction.
- Specified by:
callBuilder in interface Instruction- Overrides:
callBuilder in class GenericStartInstruction
- Parameters:
builder - the TemplateBuilder to be called back
- Throws:
ParseException
process
public short process(TemplateWriteableHashModel modelRoot,
java.io.Writer out,
TemplateRuntimeHandler eventHandler)
throws java.io.IOException
- Processes the
<list ... > or
<foreach ... > instruction.
- Parameters:
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.
- Returns:
- an exit code indicating how the process terminated, typically
used for short-circuiting template processing
- Throws:
java.io.IOException - an IO error occurred during processing
toString
public java.lang.String toString()
- Returns a string representation of the object.
- Overrides:
toString in class java.lang.Object
- Returns:
- a
String representing this instruction subtree