org.apache.commons.collections.functors

Class ChainedTransformer

Implemented Interfaces:
Serializable, Transformer

public class ChainedTransformer
extends java.lang.Object
implements Transformer, Serializable

Transformer implementation that chains the specified transformers together.

The input object is passed to the first transformer. The transformed result is passed to the second transformer and so on.

Version:
$Revision: 1.7 $ $Date: 2004/05/16 11:36:31 $

Author:
Stephen Colebourne

Since:
Commons Collections 3.0

Constructor Summary

ChainedTransformer(Transformer[] transformers)
Constructor that performs no validation.

Method Summary

static Transformer
getInstance(Collection transformers)
Create a new Transformer that calls each transformer in turn, passing the result into the next transformer.
static Transformer
getInstance(Transformer transformer1, Transformer transformer2)
Factory method that performs validation.
static Transformer
getInstance(Transformer[] transformers)
Factory method that performs validation and copies the parameter array.
Transformer[]
getTransformers()
Gets the transformers, do not modify the array.
Object
transform(Object object)
Transforms the input to result via each decorated transformer

Constructor Details

ChainedTransformer

public ChainedTransformer(Transformer[] transformers)
Constructor that performs no validation. Use getInstance if you want that.

Parameters:
transformers - the transformers to chain, not copied, no nulls

Method Details

getInstance

public static Transformer getInstance(Collection transformers)
Create a new Transformer that calls each transformer in turn, passing the result into the next transformer. The ordering is that of the iterator() method on the collection.

Parameters:
transformers - a collection of transformers to chain

Returns:
the chained transformer


getInstance

public static Transformer getInstance(Transformer transformer1,
                                      Transformer transformer2)
Factory method that performs validation.

Parameters:
transformer1 - the first transformer, not null
transformer2 - the second transformer, not null

Returns:
the chained transformer


getInstance

public static Transformer getInstance(Transformer[] transformers)
Factory method that performs validation and copies the parameter array.

Parameters:
transformers - the transformers to chain, copied, no nulls

Returns:
the chained transformer


getTransformers

public Transformer[] getTransformers()
Gets the transformers, do not modify the array.

Returns:
the transformers

Since:
Commons Collections 3.1


transform

public Object transform(Object object)
Transforms the input to result via each decorated transformer
Specified by:
transform in interface Transformer

Parameters:
object - the input object passed to the first transformer

Returns:
the transformed result


Copyright © 2001-2005 Apache Software Foundation. All Rights Reserved.