au.com.prunge.jgenfile.impl
Class CollectionItemIterator

java.lang.Object
  |
  +--au.com.prunge.jgenfile.impl.CollectionItemIterator
All Implemented Interfaces:
ItemIterator

public class CollectionItemIterator
extends Object
implements ItemIterator

An iterator that uses a java.util.Iterator to get items.

Version:
1.0
Author:
Peter Runge

Constructor Summary
CollectionItemIterator(Iterator iterator)
          Constructs a CollectionItemIterator.
 
Method Summary
protected  void checkClose()
          Checks if the iterator has been closed.
 void close()
          Closes the iterator.
 boolean hasNext()
          Returns true if the iteration has more elements.
 au.com.prunge.jgenfile.Item next()
          Returns the next item in the iteration.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CollectionItemIterator

public CollectionItemIterator(Iterator iterator)
Constructs a CollectionItemIterator.

Parameters:
iterator - the collection iterator to use.
Throws:
NullPointerException - if iterator is null.
Method Detail

close

public void close()
           throws JGenFileException
Description copied from interface: ItemIterator
Closes the iterator. No more elements can be retrieved with this iterator after this method is called.

Specified by:
close in interface ItemIterator
Throws:
JGenFileException - if an error occurs closing the iterator.
See Also:
ItemIterator.close()

hasNext

public boolean hasNext()
                throws ClosedIteratorException,
                       JGenFileException
Description copied from interface: ItemIterator
Returns true if the iteration has more elements. (In other words, returns true if next would return an element rather than throwing an exception.)

Specified by:
hasNext in interface ItemIterator
Returns:
true if the iteration has more elements, false if not.
Throws:
JGenFileException - if another error occurs.
ClosedIteratorException - if the iterator has been closed.
See Also:
ItemIterator.hasNext()

checkClose

protected void checkClose()
                   throws ClosedIteratorException
Checks if the iterator has been closed. If it has throw an exception.

Throws:
ClosedIteratorException - if the iterator has been closed.

next

public au.com.prunge.jgenfile.Item next()
                                 throws NoSuchElementException,
                                        ClosedIteratorException,
                                        JGenFileException
Description copied from interface: ItemIterator
Returns the next item in the iteration.

Specified by:
next in interface ItemIterator
Returns:
the next item in the iteration.
Throws:
NoSuchElementException - if there are no more items in the iteration.
ClosedIteratorException - if the iterator has been closed.
JGenFileException - if another error occurs.
See Also:
ItemIterator.next()