Package freemarker.template
Interface TransformControl
-
public interface TransformControlAn interface that can be implemented by writers returned fromTemplateTransformModel.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.
-
-
Field Summary
Fields Modifier and Type Field Description static intEND_EVALUATIONConstant returned fromafterBody()that tells the template engine to end the transform and close the writer.static intEVALUATE_BODYConstant returned fromonStart()that tells the template engine to evaluate the body.static intREPEAT_EVALUATIONConstant returned fromafterBody()that tells the template engine to repeat transform body evaluation and feed it again to the transform.static intSKIP_BODYConstant returned fromonStart()that tells the template engine to skip evaluation of the body.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description intafterBody()Called after the body has been evaluated.voidonError(java.lang.Throwable t)Called if any exception occurs during the transform between theTemplateTransformModel.getWriter(java.io.Writer, java.util.Map)call and theWriter.close()call.intonStart()Called before the body is evaluated for the first time.
-
-
-
Field Detail
-
REPEAT_EVALUATION
static final int REPEAT_EVALUATION
Constant returned fromafterBody()that tells the template engine to repeat transform body evaluation and feed it again to the transform.- See Also:
- Constant Field Values
-
END_EVALUATION
static final int END_EVALUATION
Constant returned fromafterBody()that tells the template engine to end the transform and close the writer.- See Also:
- Constant Field Values
-
SKIP_BODY
static final int SKIP_BODY
Constant returned fromonStart()that tells the template engine to skip evaluation of the body.- See Also:
- Constant Field Values
-
EVALUATE_BODY
static final int EVALUATE_BODY
Constant returned fromonStart()that tells the template engine to evaluate the body.- See Also:
- Constant Field Values
-
-
Method Detail
-
onStart
int onStart() throws TemplateModelException, java.io.IOExceptionCalled before the body is evaluated for the first time.- Returns:
- SKIP_BODY if the transform wants to ignore the body. In this
case, only
Writer.close()is called next and processing ends. - EVALUATE_BODY to normally evaluate the body of the transform and feed it to the writer
- SKIP_BODY if the transform wants to ignore the body. In this
case, only
- Throws:
TemplateModelExceptionjava.io.IOException
-
afterBody
int afterBody() throws TemplateModelException, java.io.IOExceptionCalled 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.
- Throws:
TemplateModelExceptionjava.io.IOException
-
onError
void onError(java.lang.Throwable t) throws java.lang.ThrowableCalled if any exception occurs during the transform between theTemplateTransformModel.getWriter(java.io.Writer, java.util.Map)call and theWriter.close()call.- Parameters:
t- the throwable that represents the exception. It can be any non-checked throwable, as well asTemplateExceptionandIOException.- Throws:
java.lang.Throwable- is recommended that the methods rethrow the received throwable. If the method wants to throw another throwable, it should either throw a non-checked throwable, or an instance ofTemplateExceptionandIOException. Throwing any other checked exception will cause the engine to rethrow it as aUndeclaredThrowableException.
-
-