com.townleyenterprises.common
Class CountingIterator
java.lang.Object
com.townleyenterprises.common.CountingIterator
- All Implemented Interfaces:
- java.util.Iterator
- public final class CountingIterator
- extends java.lang.Object
- implements java.util.Iterator
This class provides a very simple counting decorator for the
java.util.Iterator class. It is useful for restricting the amount
of data retrieved without actually having to track this in
application code.
- Version:
- $Id: CountingIterator.java,v 1.3 2004/07/28 10:33:58 atownley Exp $
- Author:
- Andrew S. Townley
Constructor Summary |
CountingIterator(java.util.Iterator i,
int c)
The constructor initializes the decorator with the number
of elements which should be returned. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
CountingIterator
public CountingIterator(java.util.Iterator i,
int c)
- The constructor initializes the decorator with the number
of elements which should be returned.
- Parameters:
i
- the iterator to decoratec
- the number of elements to return
hasNext
public boolean hasNext()
- Specified by:
hasNext
in interface java.util.Iterator
next
public java.lang.Object next()
- Specified by:
next
in interface java.util.Iterator
remove
public void remove()
throws java.lang.UnsupportedOperationException,
java.lang.IllegalStateException
- Specified by:
remove
in interface java.util.Iterator
- Throws:
java.lang.UnsupportedOperationException
java.lang.IllegalStateException
Copyright © 2002-2004, Andrew S. Townley and Townley Enterprises. All Rights Reserved.
This project is hosted on http://te-code.sourceforge.net.