org.apache.commons.collections.iterators
Class TransformIterator

java.lang.Object
  |
  +--org.apache.commons.collections.iterators.ProxyIterator
        |
        +--org.apache.commons.collections.iterators.TransformIterator
All Implemented Interfaces:
Iterator

public class TransformIterator
extends ProxyIterator

A Proxy Iterator which uses a Transformer instance to transform the contents of the Iterator into some other form

Since:
1.0
Author:
James Strachan

Constructor Summary
TransformIterator()
          Constructs a new TransformIterator that will not function until the setIterator method is invoked.
TransformIterator(Iterator iterator)
          Constructs a new TransformIterator that won't transform elements from the given iterator.
TransformIterator(Iterator iterator, Transformer transformer)
          Constructs a new TransformIterator that will use the given iterator and transformer.
 
Method Summary
 Transformer getTransformer()
          Getter for property transformer.
 Object next()
          Returns the next element from the underlying iterator.
 void setTransformer(Transformer transformer)
          Setter for property transformer.
protected  Object transform(Object source)
          Transforms the given object using the transformer.
 
Methods inherited from class org.apache.commons.collections.iterators.ProxyIterator
getIterator, hasNext, remove, setIterator
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TransformIterator

public TransformIterator()
Constructs a new TransformIterator that will not function until the setIterator method is invoked.


TransformIterator

public TransformIterator(Iterator iterator)
Constructs a new TransformIterator that won't transform elements from the given iterator.

Parameters:
iterator - the iterator to use

TransformIterator

public TransformIterator(Iterator iterator,
                         Transformer transformer)
Constructs a new TransformIterator that will use the given iterator and transformer. If the given transformer is null, then objects will not be transformed.

Parameters:
iterator - the iterator to use
transformer - the transformer to use
Method Detail

getTransformer

public Transformer getTransformer()
Getter for property transformer.

Returns:
Value of property transformer.

next

public Object next()
Description copied from class: ProxyIterator
Returns the next element from the underlying iterator.

Specified by:
next in interface Iterator
Overrides:
next in class ProxyIterator
Returns:
the next element from the underlying iterator

setTransformer

public void setTransformer(Transformer transformer)
Setter for property transformer.

Parameters:
transformer - New value of property transformer.

transform

protected Object transform(Object source)
Transforms the given object using the transformer. If the transformer is null, the original object is returned as-is.

Parameters:
source - the object to transform
Returns:
the transformed object


Copyright © 2001-2002 Apache Software Foundation. Documenation generated February 22 2003.