|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.xshare.base.iterator.TransformatorIterator
Iterator with the ability to transform the elements of a given iteration according to the users specification before returning them.
... Collection cats = ... ... public void getCollectionOfPets() { return new TransformatorIterator(cats.iterator(), new UnaryFunction() { public Object exec(Object aCat) { return new Pet((Cat)aCat); } }); }
remove()
method is not supported, since
the 'clients' of this iteration are not working
on the real iteration.
null
is a valid return value
for an iteration, the used transforming function
must be able to handle null
as argument.
Constructor Summary | |
TransformatorIterator(java.util.Iterator aSourceIterator,
UnaryFunction aTransformingFunction)
Creates a new instance of this iterator for a given iteration whose elements are transformed by a given function. |
Method Summary | |
boolean |
hasNext()
Checks if there are more elements return or not. |
java.lang.Object |
next()
Returns the next object. |
void |
remove()
This operation is not supported for this type of iterator, since the 'clients' of this iteration does not work directly on the source iteration. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public TransformatorIterator(java.util.Iterator aSourceIterator, UnaryFunction aTransformingFunction)
aSourceIterator
- a Iterator object
pointing to the source iteration for this iterator.aTransformingFunction
- a UnaryFunction
object
specifing the transformation process for e single element
of the source iteration.
- Throws:
java.lang.NullPointerException
- if one of both elements is
null
.
Method Detail |
public void remove()
remove
in interface java.util.Iterator
java.lang.UnsupportedOperationException
- if this method is
called since it is not supported.public java.lang.Object next()
next
in interface java.util.Iterator
java.util.NoSuchElementException
- if hasNext()
returns
false
.hasNext()
public boolean hasNext()
hasNext
in interface java.util.Iterator
boolean
value which is true
if there are elements left to return via next()
.
Otherwise false
is returned.next()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |