com.isti.util
Class ModIterator

java.lang.Object
  extended by com.isti.util.ModIterator
All Implemented Interfaces:
java.util.Enumeration, java.util.Iterator

public class ModIterator
extends java.lang.Object
implements java.util.Iterator, java.util.Enumeration

Class ModIterator is a modified version of an iterator that uses less resources when only one item is available and that can (optionally) use a copy of the given list for iteration, allowing the list to be structurally modified while being iterated through. A 'Collection' may also be given.


Field Summary
protected  boolean itemsRemainingFlag
           
protected  java.lang.Object singleItemObj
           
protected  java.util.Iterator sourceIterObj
           
 
Constructor Summary
ModIterator(java.util.Collection listObj)
          Creates a modified version of an iterator.
ModIterator(java.util.Collection listObj, boolean useCopyFlag)
          Creates a modified version of an iterator.
 
Method Summary
 boolean hasMoreElements()
          Returns true if the enumeration has more elements.
 boolean hasNext()
          Returns true if the iteration has more elements.
 java.lang.Object next()
          Returns the next element in the iteration.
 java.lang.Object nextElement()
          Returns the next element in the enumeration.
 void remove()
          This operation is not supported.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sourceIterObj

protected final java.util.Iterator sourceIterObj

singleItemObj

protected final java.lang.Object singleItemObj

itemsRemainingFlag

protected boolean itemsRemainingFlag
Constructor Detail

ModIterator

public ModIterator(java.util.Collection listObj,
                   boolean useCopyFlag)
Creates a modified version of an iterator.

Parameters:
listObj - the 'List' (or 'Collection') object to be iterated though, or null for none.
useCopyFlag - if true then a copy of the given list is used for iteration, allowing the list to be structurally modified while being iterated through.

ModIterator

public ModIterator(java.util.Collection listObj)
Creates a modified version of an iterator. A copy of the given list is used for iteration, allowing the list to be structurally modified while being iterated through.

Parameters:
listObj - the 'List' (or 'Collection') object to be iterated though, or null for none.
Method Detail

hasMoreElements

public boolean hasMoreElements()
Returns true if the enumeration has more elements. (In other words, returns true if nextElement would return an element rather than throwing an exception.)

Specified by:
hasMoreElements in interface java.util.Enumeration
Returns:
true if the enumeration has more elements.

hasNext

public boolean hasNext()
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 java.util.Iterator
Returns:
true if the iterator has more elements.

next

public java.lang.Object next()
Returns the next element in the iteration.

Specified by:
next in interface java.util.Iterator
Returns:
the next element in the iteration.
Throws:
java.util.NoSuchElementException - if the iteration has no more elements.

nextElement

public java.lang.Object nextElement()
Returns the next element in the enumeration.

Specified by:
nextElement in interface java.util.Enumeration
Returns:
the next element in the enumeration.
Throws:
java.util.NoSuchElementException - if the enumeration has no more elements.

remove

public void remove()
This operation is not supported.

Specified by:
remove in interface java.util.Iterator
Throws:
java.lang.UnsupportedOperationException - always throws this exception.