freemarker.ext.misc
Class TransformPipeline

java.lang.Object
  extended by freemarker.ext.misc.TransformPipeline
All Implemented Interfaces:
TemplateModel, TemplateTransformModel2, java.io.Serializable

public final class TransformPipeline
extends java.lang.Object
implements TemplateTransformModel2, java.io.Serializable

A pipeline of transform models that is itself a transform model. Transformations occur in leftmost to rightmost order. Null or empty models are considered equivalent to the null transformation, where data is simply copied from input to output without alteration. Similarly, a pipeline consisting of no transformations is also handled as a null transformation.

Since:
1.9
Version:
$Id$
Author:
Nicholas Cull
See Also:
Serialized Form

Constructor Summary
TransformPipeline(java.util.List<TemplateModel> transforms)
          Create a new transform pipeline with the given transform models.
 
Method Summary
 boolean isEmpty()
          Is there anything in this pipeline.
 java.lang.String toString()
          Returns a string representation of the object.
 void transform(java.io.Reader source, java.io.Writer target)
          Perform the requested transformations on the given data source in the given order.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TransformPipeline

public TransformPipeline(java.util.List<TemplateModel> transforms)
Create a new transform pipeline with the given transform models.

Parameters:
transforms - an ordered list of TemplateTransformModel and TemplateTransformModel2 objects to be pipelined
Method Detail

isEmpty

public boolean isEmpty()
                throws TemplateModelException
Is there anything in this pipeline.

Specified by:
isEmpty in interface TemplateModel
Returns:
true if the pipeline is empty, otherwise false
Throws:
TemplateModelException

transform

public void transform(java.io.Reader source,
                      java.io.Writer target)
               throws java.io.IOException,
                      TemplateModelException
Perform the requested transformations on the given data source in the given order.

Specified by:
transform in interface TemplateTransformModel2
Parameters:
source - the input data to be transformed
target - the data after being fed through all transformations
Throws:
java.io.IOException
TemplateModelException

toString

public java.lang.String toString()
Returns a string representation of the object.

Overrides:
toString in class java.lang.Object
Returns:
a String representation of the object.