org.apache.commons.collections.iterators
Class TransformIterator
java.lang.Object
org.apache.commons.collections.iterators.TransformIterator
- Iterator
public class TransformIterator
extends java.lang.Object
implements Iterator
Decorates an iterator such that each element returned is transformed.
$Revision: 1.9 $ $Date: 2004/02/18 00:59:50 $- James Strachan
- Stephen Colebourne
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.
|
Iterator | getIterator() - Gets the iterator this iterator is using.
|
Transformer | getTransformer() - Gets the transformer this iterator is using.
|
boolean | hasNext()
|
Object | next() - Gets the next object from the iteration, transforming it using the
current transformer.
|
void | remove()
|
void | setIterator(Iterator iterator) - Sets the iterator for this iterator to use.
|
void | setTransformer(Transformer transformer) - Sets the transformer this the iterator to use.
|
protected Object | transform(Object source) - Transforms the given object using the transformer.
|
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.
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.
iterator
- the iterator to usetransformer
- the transformer to use
getIterator
public Iterator getIterator()
Gets the iterator this iterator is using.
getTransformer
public Transformer getTransformer()
Gets the transformer this iterator is using.
hasNext
public boolean hasNext()
next
public Object next()
Gets the next object from the iteration, transforming it using the
current transformer. If the transformer is null, no transformation
occurs and the object from the iterator is returned directly.
remove
public void remove()
setIterator
public void setIterator(Iterator iterator)
Sets the iterator for this iterator to use.
If iteration has started, this effectively resets the iterator.
iterator
- the iterator to use
setTransformer
public void setTransformer(Transformer transformer)
Sets the transformer this the iterator to use.
A null transformer is a no-op transformer.
transformer
- the transformer to use
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.
source
- the object to transform
Copyright © 2001-2006 Apache Software Foundation. All Rights Reserved.