freemarker.template.instruction
Class ListInstruction

java.lang.Object
  extended by freemarker.template.instruction.GenericStartInstruction
      extended by 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.

Version:
$Id: ListInstruction.java 1162 2013-04-20 12:04:32Z run2000 $
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface freemarker.template.instruction.Instruction
Instruction.EndType
 
Nested classes/interfaces inherited from interface freemarker.template.TemplateProcessor
TemplateProcessor.ExitStatus
 
Field Summary
 
Fields inherited from class freemarker.template.instruction.GenericStartInstruction
body
 
Constructor Summary
ListInstruction(Expression listExpression, Identifier indexVariable)
          Constructs a list/foreach instruction containing the list variable and the index variable.
 
Method Summary
 TemplateProcessor callBuilder(TemplateBuilder builder)
          Call the TemplateBuilder with this list instruction.
 TemplateProcessor.ExitStatus process(TemplateProcessorParameters p)
          Processes the <list ...
 boolean testEndInstruction(Instruction endInstruction)
          Is this the right kind of instruction for the given EndInstruction?
 java.lang.String toString()
          Returns a string representation of the object.
 
Methods inherited from class freemarker.template.instruction.GenericStartInstruction
getEndType, isEndInstruction, setBody
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

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
Method Detail

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 TemplateProcessor.ExitStatus process(TemplateProcessorParameters p)
                                     throws java.io.IOException
Processes the <list ... > or <foreach ... > instruction.

Parameters:
p - template processing parameters
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