Package de.tu_bs.isbs.util.io
Interface IOIterator<E>
- Type Parameters:
E-
public interface IOIterator<E>
Ersatz für java.util.Iterator. Hat eine zusätzliche Methode close().
Dies ermöglicht es, eine zu Grunde liegende externe Datenquelle (z.B. Datei
oder ResultSet) zu schließen, wenn der Iterator aufgegeben werden soll und
wenn er nicht vollständig durchlaufen wird.
Siehe auch die Anmerkungen in
IOIteratorException.
Anmerkung: Es wird nicht von Iterator geerbt, weil dann keine zusätzlichen Exceptions in die Methodensignaturen aufgenommen werden könnten.
- Author:
- Stefan
-
Method Summary
Modifier and Type Method Description voidclose()Closes the underlying data source.booleanhasNext()Returnstrueif the iteration has more elements.Enext()Returns the next element in the iteration.voidremove()Removes from the underlying collection the last element returned by this iterator (optional operation).
-
Method Details
-
hasNext
Returnstrueif the iteration has more elements. (In other words, returnstrueifnext()would return an element rather than throwing an exception.)- Returns:
trueif the iteration has more elements- Throws:
IOIteratorException- See Also:
Iterator.hasNext()
-
next
Returns the next element in the iteration.- Returns:
- the next element in the iteration
- Throws:
java.util.NoSuchElementException- if the iteration has no more elementsIOIteratorException- See Also:
Iterator.next()
-
remove
Removes from the underlying collection the last element returned by this iterator (optional operation). This method can be called only once per call tonext(). The behavior of an iterator is unspecified if the underlying collection is modified while the iteration is in progress in any way other than by calling this method.- Throws:
IOIteratorExceptionjava.lang.UnsupportedOperationException- if theremoveoperation is not supported by this iteratorjava.lang.IllegalStateException- if thenextmethod has not yet been called, or theremovemethod has already been called after the last call to thenextmethod- See Also:
Iterator.remove()
-
close
void close()Closes the underlying data source. Throws no checked-exception: Any exception should be handled by implementation.
-