net.sf.jelly.apt.strategies
Class TemplateLoopStrategy<I,B extends TemplateBlock>

java.lang.Object
  extended by net.sf.jelly.apt.strategies.TemplateStrategyControl<B>
      extended by net.sf.jelly.apt.strategies.TemplateBlockStrategy<B>
          extended by net.sf.jelly.apt.strategies.TemplateLoopStrategy<I,B>
All Implemented Interfaces:
TemplateStrategy<B>
Direct Known Subclasses:
DeclarationLoopStrategy, ThrownTypeLoopStrategy

public abstract class TemplateLoopStrategy<I,B extends TemplateBlock>
extends TemplateBlockStrategy<B>

A template stategy that loops its block.

Author:
Ryan Heaton

Constructor Summary
TemplateLoopStrategy()
           
 
Method Summary
protected abstract  java.util.Iterator<I> getLoop(TemplateModel model)
          Get the loop.
 boolean preProcess(B block, TemplateOutput<B> output, TemplateModel model)
          Gets the loop, and sets up the model for the first iteration.
 boolean processBody(B block, TemplateOutput<B> output, TemplateModel model)
          Set up the model for the loop and process the body.
protected  void setupModelForLoop(TemplateModel model, I var, int index)
          Sets up the model for the current loop.
 
Methods inherited from class net.sf.jelly.apt.strategies.TemplateBlockStrategy
postProcess
 
Methods inherited from class net.sf.jelly.apt.strategies.TemplateStrategyControl
invoke
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TemplateLoopStrategy

public TemplateLoopStrategy()
Method Detail

getLoop

protected abstract java.util.Iterator<I> getLoop(TemplateModel model)
                                          throws TemplateException
Get the loop.

Parameters:
model - The model to use as necessary.
model -
Returns:
The loop.
Throws:
TemplateException

setupModelForLoop

protected void setupModelForLoop(TemplateModel model,
                                 I var,
                                 int index)
                          throws TemplateException
Sets up the model for the current loop. Default implementation does nothing.

Parameters:
model - The model.
var - The loop variable.
index - The loop index.
Throws:
TemplateException

preProcess

public boolean preProcess(B block,
                          TemplateOutput<B> output,
                          TemplateModel model)
                   throws java.io.IOException,
                          TemplateException
Gets the loop, and sets up the model for the first iteration.

Overrides:
preProcess in class TemplateBlockStrategy<B extends TemplateBlock>
Parameters:
block - The block.
output - The output.
model - The model.
Returns:
Whether to evaluate the body.
Throws:
java.io.IOException
TemplateException

processBody

public boolean processBody(B block,
                           TemplateOutput<B> output,
                           TemplateModel model)
                    throws java.io.IOException,
                           TemplateException
Set up the model for the loop and process the body.

Overrides:
processBody in class TemplateBlockStrategy<B extends TemplateBlock>
Parameters:
block - The block.
output - The output.
model - The model.
Returns:
Whether to do the loop again.
Throws:
java.io.IOException
TemplateException