com.cafesoft.core.util
Class ImmutableIterator

java.lang.Object
  extended by com.cafesoft.core.util.ImmutableIterator
All Implemented Interfaces:
Iterator

public class ImmutableIterator
extends Object
implements Iterator

ImmutableIterator overrides the remove method of java.util.Iterator for situations where the items must not be taken out of the backing collection.


Constructor Summary
ImmutableIterator(Iterator iterator)
          Create a new ImmutableIterator
 
Method Summary
 boolean hasNext()
          Check for a next Object.
 Object next()
          Get the next Object.
 void remove()
          Unsupported.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ImmutableIterator

public ImmutableIterator(Iterator iterator)
Create a new ImmutableIterator

Parameters:
iterator - the Iterator to be wrapped.
Method Detail

hasNext

public boolean hasNext()
Check for a next Object.

Specified by:
hasNext in interface Iterator
Returns:
true if there is another Object, else false.

next

public Object next()
            throws NoSuchElementException
Get the next Object.

Specified by:
next in interface Iterator
Returns:
the next Object, if one exists.
Throws:
NoSuchElementException - if another Object does not exist.

remove

public void remove()
            throws UnsupportedOperationException
Unsupported.

Specified by:
remove in interface Iterator
Throws:
UnsupportedOperationException - is thrown in all cases because this backing Collection is immutable via this Iterator.


Generated on 10:38:35 AM April 14, 2011, © 1996-2010 Cafésoft LLC. All rights reserved.