org.apache.commons.betwixt.expression
Class IteratorExpression.EnumerationIterator

java.lang.Object
  extended byorg.apache.commons.betwixt.expression.IteratorExpression.EnumerationIterator
All Implemented Interfaces:
java.util.Iterator
Enclosing class:
IteratorExpression

private static final class IteratorExpression.EnumerationIterator
extends java.lang.Object
implements java.util.Iterator

Adapter to make Enumerationinstances appear to be Iteratorinstances. Originated in commons-collections. Added as a private inner class to break dependency.

Author:
James Strachan , Daniel Rall

Field Summary
private  java.util.Collection collection
          The collection to remove elements from
private  java.util.Enumeration enumeration
          The enumeration being converted
private  java.lang.Object last
          The last object retrieved
 
Constructor Summary
IteratorExpression.EnumerationIterator()
          Constructs a new EnumerationIterator that will not function until setEnumeration(Enumeration) is called.
IteratorExpression.EnumerationIterator(java.util.Enumeration enumeration)
          Constructs a new EnumerationIterator that provides an iterator view of the given enumeration.
IteratorExpression.EnumerationIterator(java.util.Enumeration enumeration, java.util.Collection collection)
          Constructs a new EnumerationIterator that will remove elements from the specified collection.
 
Method Summary
 java.util.Enumeration getEnumeration()
          Returns the underlying enumeration.
 boolean hasNext()
          Returns true if the underlying enumeration has more elements.
 java.lang.Object next()
          Returns the next object from the enumeration.
 void remove()
          Removes the last retrieved element if a collection is attached.
 void setEnumeration(java.util.Enumeration enumeration)
          Sets the underlying enumeration.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

collection

private java.util.Collection collection
The collection to remove elements from


enumeration

private java.util.Enumeration enumeration
The enumeration being converted


last

private java.lang.Object last
The last object retrieved

Constructor Detail

IteratorExpression.EnumerationIterator

public IteratorExpression.EnumerationIterator()
Constructs a new EnumerationIterator that will not function until setEnumeration(Enumeration) is called.


IteratorExpression.EnumerationIterator

public IteratorExpression.EnumerationIterator(java.util.Enumeration enumeration)
Constructs a new EnumerationIterator that provides an iterator view of the given enumeration.

Parameters:
enumeration - the enumeration to use

IteratorExpression.EnumerationIterator

public IteratorExpression.EnumerationIterator(java.util.Enumeration enumeration,
                                              java.util.Collection collection)
Constructs a new EnumerationIterator that will remove elements from the specified collection.

Parameters:
enumeration - the enumeration to use
collection - the collection to remove elements form
Method Detail

hasNext

public boolean hasNext()
Returns true if the underlying enumeration has more elements.

Specified by:
hasNext in interface java.util.Iterator
Returns:
true if the underlying enumeration has more elements
Throws:
java.lang.NullPointerException - if the underlying enumeration is null

next

public java.lang.Object next()
Returns the next object from the enumeration.

Specified by:
next in interface java.util.Iterator
Returns:
the next object from the enumeration
Throws:
java.lang.NullPointerException - if the enumeration is null

remove

public void remove()
Removes the last retrieved element if a collection is attached.

Functions if an associated Collection is known. If so, the first occurrence of the last returned object from this iterator will be removed from the collection.

Specified by:
remove in interface java.util.Iterator
Throws:
java.lang.IllegalStateException - next() not called.
java.lang.UnsupportedOperationException - if no associated collection

getEnumeration

public java.util.Enumeration getEnumeration()
Returns the underlying enumeration.

Returns:
the underlying enumeration

setEnumeration

public void setEnumeration(java.util.Enumeration enumeration)
Sets the underlying enumeration.

Parameters:
enumeration - the new underlying enumeration