com.alexkasko.springjdbc.iterable
Class CloseableIterable<T>

java.lang.Object
  extended by com.alexkasko.springjdbc.iterable.CloseableIterable<T>
All Implemented Interfaces:
Closeable, Iterable<T>

public abstract class CloseableIterable<T>
extends Object
implements Iterable<T>, Closeable

Specialized Iterable partial implementation, returns closable iterators. This class is not used directly in this library and may be used for processing possible results for multiple queries in "passive" mode (no DB resources are used until client call to iterator()). Retains references to returned iterators and closes them on close() call.

Author:
alexkasko Date: 6/21/13

Field Summary
protected  List<CloseableIterator<T>> iters
           
 
Constructor Summary
CloseableIterable()
           
 
Method Summary
 void close()
          
protected abstract  CloseableIterator<T> closeableIterator()
          Implementation should return new CloseableIterator instance
 boolean isClosed()
          Returns true if all produces iterators are closed
 CloseableIterator<T> iterator()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

iters

protected List<CloseableIterator<T>> iters
Constructor Detail

CloseableIterable

public CloseableIterable()
Method Detail

closeableIterator

protected abstract CloseableIterator<T> closeableIterator()
Implementation should return new CloseableIterator instance

Returns:
closeable iterator

iterator

public CloseableIterator<T> iterator()

Specified by:
iterator in interface Iterable<T>

close

public void close()

Specified by:
close in interface Closeable

isClosed

public boolean isClosed()
Returns true if all produces iterators are closed

Returns:
true if all produces iterators are closed false otherwise


Copyright © 2013. All Rights Reserved.