freemarker.template

Interface TransformControl

public interface TransformControl

An interface that can be implemented by writers returned from TemplateTransformModel.getWriter(java.io.Writer, java.util.Map). The methods on this interfaces are callbacks that will be called by the template engine and that give the writer a chance to better control the evaluation of the transform body. The writer can instruct the engine to skip or to repeat body evaluation, and gets notified about exceptions that are thrown during the body evaluation.
Version:
$Id: TransformControl.java,v 1.11 2005/06/16 18:13:58 ddekany Exp $
Author:
Attila Szegedi

Field Summary

static int
END_EVALUATION
Constant returned from afterBody() that tells the template engine to end the transform and close the writer.
static int
EVALUATE_BODY
Constant returned from onStart() that tells the template engine to evaluate the body.
static int
REPEAT_EVALUATION
Constant returned from afterBody() that tells the template engine to repeat transform body evaluation and feed it again to the transform.
static int
SKIP_BODY
Constant returned from onStart() that tells the template engine to skip evaluation of the body.

Method Summary

int
afterBody()
Called after the body has been evaluated.
void
onError(Throwable t)
Called if any exception occurs during the transform between the TemplateTransformModel.getWriter(java.io.Writer, java.util.Map) call and the java.io.Writer.close() call.
int
onStart()
Called before the body is evaluated for the first time.

Field Details

END_EVALUATION

public static final int END_EVALUATION
Constant returned from afterBody() that tells the template engine to end the transform and close the writer.
Field Value:
1

EVALUATE_BODY

public static final int EVALUATE_BODY
Constant returned from onStart() that tells the template engine to evaluate the body.
Field Value:
1

REPEAT_EVALUATION

public static final int REPEAT_EVALUATION
Constant returned from afterBody() that tells the template engine to repeat transform body evaluation and feed it again to the transform.
Field Value:
0

SKIP_BODY

public static final int SKIP_BODY
Constant returned from onStart() that tells the template engine to skip evaluation of the body.
Field Value:
0

Method Details

afterBody

public int afterBody()
            throws TemplateModelException,
                   IOException
Called after the body has been evaluated.
Returns:
  • END_EVALUATION if the transformation should be ended.
  • REPEAT_EVALUATION to have the engine re-evaluate the transform body and feed it again to the writer.

onError

public void onError(Throwable t)
            throws Throwable
Called if any exception occurs during the transform between the TemplateTransformModel.getWriter(java.io.Writer, java.util.Map) call and the java.io.Writer.close() call.

onStart

public int onStart()
            throws TemplateModelException,
                   IOException
Called before the body is evaluated for the first time.
Returns:
  • SKIP_BODY if the transform wants to ignore the body. In this case, only java.io.Writer.close() is called next and processing ends.
  • EVALUATE_BODY to normally evaluate the body of the transform and feed it to the writer