net.sf.jelly.apt.freemarker
Class FreemarkerTemplateBlock
java.lang.Object
java.io.Writer
java.io.FilterWriter
net.sf.jelly.apt.freemarker.FreemarkerTemplateBlock
- All Implemented Interfaces:
- freemarker.template.TransformControl, java.io.Closeable, java.io.Flushable, java.lang.Appendable, TemplateBlock, TemplateOutput<FreemarkerTemplateBlock>
public class FreemarkerTemplateBlock
- extends java.io.FilterWriter
- implements TemplateBlock, TemplateOutput<FreemarkerTemplateBlock>, freemarker.template.TransformControl
A freemarker template block. The block buffers its value and invokes the strategy when finished.
- Author:
- Ryan Heaton
Fields inherited from class java.io.FilterWriter |
out |
Fields inherited from class java.io.Writer |
lock |
Fields inherited from interface freemarker.template.TransformControl |
END_EVALUATION, EVALUATE_BODY, REPEAT_EVALUATION, SKIP_BODY |
Methods inherited from class java.io.FilterWriter |
flush, write, write, write |
Methods inherited from class java.io.Writer |
append, append, append, write, write |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
FreemarkerTemplateBlock
protected FreemarkerTemplateBlock(java.io.Writer out,
TemplateStrategyControl strategy,
java.lang.String transformName)
onStart
public int onStart()
throws freemarker.template.TemplateModelException,
java.io.IOException
- Pre-process the strategy.
- Specified by:
onStart
in interface freemarker.template.TransformControl
- Returns:
- Whether to evaluate the block.
- Throws:
freemarker.template.TemplateModelException
java.io.IOException
afterBody
public int afterBody()
throws freemarker.template.TemplateModelException,
java.io.IOException
- Process the strategy.
- Specified by:
afterBody
in interface freemarker.template.TransformControl
- Returns:
- Whether to continue the loop.
- Throws:
freemarker.template.TemplateModelException
java.io.IOException
onError
public void onError(java.lang.Throwable throwable)
throws java.lang.Throwable
- Just throw it.
- Specified by:
onError
in interface freemarker.template.TransformControl
- Throws:
java.lang.Throwable
redirect
public void redirect(FreemarkerTemplateBlock block,
java.io.Writer writer)
throws java.io.IOException,
TemplateException
- Redirect the output.
- Specified by:
redirect
in interface TemplateOutput<FreemarkerTemplateBlock>
- Parameters:
block
- The block to redirect.writer
- The writer to which to redirect the output.
- Throws:
java.io.IOException
TemplateException
close
public void close()
throws java.io.IOException
- Specified by:
close
in interface java.io.Closeable
- Overrides:
close
in class java.io.FilterWriter
- Throws:
java.io.IOException
write
public void write(FreemarkerTemplateBlock block)
throws java.io.IOException,
TemplateException
- No-op, as the work of writing the block will be done by Freemarker.
- Specified by:
write
in interface TemplateOutput<FreemarkerTemplateBlock>
- Parameters:
block
- The block of template code to write.
- Throws:
java.io.IOException
TemplateException