org.springframework.batch.item.file.transform
Class RecursiveCollectionItemTransformer
java.lang.Object
org.springframework.batch.item.file.transform.RecursiveCollectionItemTransformer
- All Implemented Interfaces:
- ItemTransformer
public class RecursiveCollectionItemTransformer
- extends Object
- implements ItemTransformer
An implementation of ItemTransformer
that treats its argument
specially if it is an array or collection. In this case it loops though,
calling itself on each member in turn, until it encounters a non collection.
At this point, if the item is a String, that is used, or else it is passed to
the delegate ItemTransformer
. The transformed single item Strings
are all concatenated with line separators.
- Author:
- Dave Syer
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
RecursiveCollectionItemTransformer
public RecursiveCollectionItemTransformer()
setDelegate
public void setDelegate(ItemTransformer delegate)
- Public setter for the
ItemTransformer
to use on single items,
that are not Strings. This can be used to strategise the conversion of
collection and array elements to a String, e.g. via a subclass of
LineAggregatorItemTransformer
.
N.B. if the delegate returns an array or collection, it will not be
treated the same way as the original item passed in for transformation.
Rather, in this case, it will simply be converted immediately to a String
by calling its toString().
- Parameters:
delegate
- the delegate to set. Defaults to a pass through.
transform
public Object transform(Object input)
throws Exception
- Specified by:
transform
in interface ItemTransformer
- Throws:
Exception
stringify
public String stringify(Object item)
throws Exception
- Throws:
Exception
Copyright © 2009 SpringSource. All Rights Reserved.