JTemporal Home
Tutorial

net.sf.jtemporal.util
Interface CloseableIterator<V>

All Superinterfaces:
java.util.Iterator<V>
All Known Implementing Classes:
EmptyIterator, IteratorFilter, SimpleCloseableIterator

public interface CloseableIterator<V>
extends java.util.Iterator<V>

An iterator the should be closed as soon it is not used anymore.
This is useful to avoid waiting the garbage collection to free resources, such as database resources.

Version:
$Id: CloseableIterator.java,v 1.5 2007/08/22 19:09:05 tabeck Exp $

Method Summary
 void close()
          Closes the iterator.
 boolean hasNext()
           As soon the method returns false the cursor is automatically closed.
 boolean isOpen()
          Checks whether the iterator is open, or already closed.
 
Methods inherited from interface java.util.Iterator
next, remove
 

Method Detail

close

void close()
Closes the iterator.
Once this method has been called, the iterator behaves as it had reached the end of the list, and does not return more element.
This call releases all the linked resources (for example a database cursor).
It is recommended to call this method when you do not want to iterate until the last element.
If the cursor is already closed, this method just returns, with no error.


isOpen

boolean isOpen()
Checks whether the iterator is open, or already closed.

Returns:
true if the cursor is open.

hasNext

boolean hasNext()
As soon the method returns false the cursor is automatically closed.
This implies that if you want to remove the last element you must call Iterator.remove() before calling this method again.

Specified by:
hasNext in interface java.util.Iterator<V>
See Also:
Iterator.hasNext()

JTemporal Home
Tutorial