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 void
close()
Closes the underlying data source.boolean
hasNext()
Returnstrue
if the iteration has more elements.E
next()
Returns the next element in the iteration.void
remove()
Removes from the underlying collection the last element returned by this iterator (optional operation).
-
Method Details
-
hasNext
Returnstrue
if the iteration has more elements. (In other words, returnstrue
ifnext()
would return an element rather than throwing an exception.)- Returns:
true
if 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:
IOIteratorException
java.lang.UnsupportedOperationException
- if theremove
operation is not supported by this iteratorjava.lang.IllegalStateException
- if thenext
method has not yet been called, or theremove
method has already been called after the last call to thenext
method- See Also:
Iterator.remove()
-
close
void close()Closes the underlying data source. Throws no checked-exception: Any exception should be handled by implementation.
-