org.apache.jackrabbit.spi.commons.iterator
Class BoundedIterator<T>

java.lang.Object
  extended by org.apache.jackrabbit.spi.commons.iterator.BoundedIterator<T>
Type Parameters:
T - element type
All Implemented Interfaces:
Iterator<T>

public class BoundedIterator<T>
extends Object
implements Iterator<T>

Implements a bounded iterator which only returns a maximum number of element from an underlying iterator starting at a given offset.


Constructor Summary
BoundedIterator(long offset, long max, Iterator<T> iterator)
          Create a new bounded iterator with a given offset and maximum
 
Method Summary
static
<T> Iterator<T>
create(long offset, long max, Iterator<T> iterator)
          Factory for creating a bounded iterator.
 boolean hasNext()
           
 T next()
           
 void remove()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BoundedIterator

public BoundedIterator(long offset,
                       long max,
                       Iterator<T> iterator)
Create a new bounded iterator with a given offset and maximum

Parameters:
offset - offset to start iteration at. Must be non negative
max - maximum elements this iterator should return. Set to -1 for all
iterator - the underlying iterator
Throws:
IllegalArgumentException - if offset is negative
Method Detail

create

public static <T> Iterator<T> create(long offset,
                                     long max,
                                     Iterator<T> iterator)
Factory for creating a bounded iterator.

Type Parameters:
T - element type
Parameters:
offset - offset to start iteration at. Must be non negative
max - maximum elements this iterator should return. Set to -1 for all
iterator - the underlying iterator
Returns:
an iterator which only returns the elements in the given bounds
See Also:
BoundedIterator(long, long, java.util.Iterator)

hasNext

public boolean hasNext()
Specified by:
hasNext in interface Iterator<T>

next

public T next()
Specified by:
next in interface Iterator<T>

remove

public void remove()
Specified by:
remove in interface Iterator<T>


Copyright © 2004-2013 The Apache Software Foundation. All Rights Reserved.