3.2.1: 2012-12-13

net.sf.basedb.util.query
Class MultiQueryIterator<E extends BasicItem>

java.lang.Object
  extended by net.sf.basedb.util.query.MultiQueryIterator<E>
All Implemented Interfaces:
Iterator<E>

public class MultiQueryIterator<E extends BasicItem>
extends Object
implements Iterator<E>

Helper class for executing multiple queries and return the result as a single iterator. The queries are executed in the order that they are given, if a query doesn't return any result, the iterator continues with the next query. As soon as a query returns at least one result, no more queries are executed.

Since:
3.2
Author:
nicklas

Field Summary
private  Iterator<? extends E> current
           
private  DbControl dc
           
private  int nextQuery
           
private  int numReturned
           
private  ItemQuery<? extends E>[] queries
           
 
Constructor Summary
private MultiQueryIterator(DbControl dc, ItemQuery<? extends E>... queries)
           
 
Method Summary
static
<E extends BasicItem>
Iterator<E>
get(DbControl dc, ItemQuery<? extends E>... queries)
          Create a new iterator for the given list of queries.
 boolean hasNext()
           
 E next()
           
 void remove()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dc

private final DbControl dc

queries

private final ItemQuery<? extends E extends BasicItem>[] queries

current

private Iterator<? extends E extends BasicItem> current

nextQuery

private int nextQuery

numReturned

private int numReturned
Constructor Detail

MultiQueryIterator

private MultiQueryIterator(DbControl dc,
                           ItemQuery<? extends E>... queries)
Method Detail

get

public static <E extends BasicItem> Iterator<E> get(DbControl dc,
                                                    ItemQuery<? extends E>... queries)
Create a new iterator for the given list of queries. There must be at least one query.

Parameters:
dc - The DbControl to use when executing the queries
queries - An array of queries to execute

hasNext

public boolean hasNext()
Specified by:
hasNext in interface Iterator<E extends BasicItem>

next

public E next()
Specified by:
next in interface Iterator<E extends BasicItem>

remove

public void remove()
Specified by:
remove in interface Iterator<E extends BasicItem>

3.2.1: 2012-12-13