net.sf.tacos.util
Class SizeRestrictingIterator

java.lang.Object
  extended by net.sf.tacos.util.SizeRestrictingIterator
All Implemented Interfaces:
Iterator

public class SizeRestrictingIterator
extends Object
implements Iterator

This class implements an Iterator which can only return a fixed number of items.

Author:
andyhot

Constructor Summary
SizeRestrictingIterator(Iterator iterator)
          Constructs an Iterator which will return at most 20 items.
SizeRestrictingIterator(Iterator iter, int size)
          Constructs an Iterator which will return at most as many items as defined by the user.
 
Method Summary
 boolean hasNext()
          
 Object next()
          
 void remove()
          
 void setMaxSize(int size)
          Set the max number of elements this iterator can return
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SizeRestrictingIterator

public SizeRestrictingIterator(Iterator iterator)
Constructs an Iterator which will return at most 20 items.

Parameters:
iterator - The 'real' iterator

SizeRestrictingIterator

public SizeRestrictingIterator(Iterator iter,
                               int size)
Constructs an Iterator which will return at most as many items as defined by the user.

Parameters:
iter - The 'real' iterator
size - How many items to return
Method Detail

setMaxSize

public void setMaxSize(int size)
Set the max number of elements this iterator can return


hasNext

public boolean hasNext()

Specified by:
hasNext in interface Iterator

next

public Object next()

Specified by:
next in interface Iterator

remove

public void remove()

Specified by:
remove in interface Iterator