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()
    Returns true 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

      boolean hasNext() throws IOIteratorException
      Returns true if the iteration has more elements. (In other words, returns true if next() would return an element rather than throwing an exception.)
      Returns:
      true if the iteration has more elements
      Throws:
      IOIteratorException
      See Also:
      Iterator.hasNext()
    • next

      E next() throws IOIteratorException, java.util.NoSuchElementException
      Returns the next element in the iteration.
      Returns:
      the next element in the iteration
      Throws:
      java.util.NoSuchElementException - if the iteration has no more elements
      IOIteratorException
      See Also:
      Iterator.next()
    • remove

      void remove() throws IOIteratorException
      Removes from the underlying collection the last element returned by this iterator (optional operation). This method can be called only once per call to next(). 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 the remove operation is not supported by this iterator
      java.lang.IllegalStateException - if the next method has not yet been called, or the remove method has already been called after the last call to the next method
      See Also:
      Iterator.remove()
    • close

      void close()
      Closes the underlying data source. Throws no checked-exception: Any exception should be handled by implementation.