|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.sf.staccatocommons.iterators.AbstractUnmodifiableIterator<A>
net.sf.staccatocommons.iterators.thriter.AbstractThriterator<A>
net.sf.staccatocommons.iterators.thriter.AdvanceThriterator<A>
net.sf.staccatocommons.iterators.UpdateCurrentThriterator<A>
A - public abstract class UpdateCurrentThriterator<A>
A thriterator that is implemented through a single message
updateCurrent(), which is both responsible for answering if there is
a current element and setting it.
This is useful when implementor does not know if it has a next element until it effectively computes it. This implementation of Thriterator resolves it by caching the temporal element p>
Typical implementation of that method is the following:
protected boolean updateCurrent() {
A element = .. compute next element ..
if ( .. element matches a criteria .. ) {
setCurrent(element);
}
}
| Constructor Summary | |
|---|---|
UpdateCurrentThriterator()
|
|
| Method Summary | |
|---|---|
void |
advanceNext()
Advances to the thriter to the position of the next element. |
A |
current()
Answers element at the current position of this Thriter. |
boolean |
hasNext()
Answers if the thriter has more elements, that is, if sending Thriter.advanceNext() would not result in a NoSuchElementException |
protected void |
setCurrent(A current)
Sets the current value of iteration. |
protected abstract void |
updateCurrent()
Sets the current element, if any. |
| Methods inherited from class net.sf.staccatocommons.iterators.thriter.AdvanceThriterator |
|---|
next |
| Methods inherited from class net.sf.staccatocommons.iterators.thriter.AbstractThriterator |
|---|
delayedCurrent, delayedNext, isEmpty |
| Methods inherited from class net.sf.staccatocommons.iterators.AbstractUnmodifiableIterator |
|---|
remove |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface java.util.Iterator |
|---|
remove |
| Constructor Detail |
|---|
public UpdateCurrentThriterator()
| Method Detail |
|---|
public final boolean hasNext()
ThriterThriter.advanceNext() would not result in a NoSuchElementException
Thriter has more elements
public final void advanceNext()
throws NoSuchElementException
Thriter
NoSuchElementException - if there are no more elementsprotected final void setCurrent(A current)
current - the current value of iterationpublic final A current()
ThriterThriter. Result of
this method if Thriter.advanceNext() was never evaluated before is
undefined.
protected abstract void updateCurrent()
setCurrent(Object) in order to indicate which is the next element.
If there is no current element - end of source has reached - implementors
must do nothing.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||