net.sf.mmm.util.collection.base
Class ReadOnlyIterator<E>

java.lang.Object
  extended by net.sf.mmm.util.collection.base.ReadOnlyIterator<E>
Type Parameters:
E - is the templated type of the elements to iterate.
All Implemented Interfaces:
Iterator<E>

public class ReadOnlyIterator<E>
extends Object
implements Iterator<E>

This is an implementation of the Iterator interface that gives a read-only view on an existing Iterator instance.
The design of the JDK sucks: if only Iterator would extend Enumeration the world could be so simple.

Author:
Joerg Hohwiller (hohwille at users.sourceforge.net)

Field Summary
private  Iterator<E> delegate
          the actual iterator instance
 
Constructor Summary
ReadOnlyIterator(Iterator<E> iterator)
          The constructor.
 
Method Summary
 boolean hasNext()
          
 E next()
          
 void remove()
          This method will always throw an exception.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

delegate

private final Iterator<E> delegate
the actual iterator instance

Constructor Detail

ReadOnlyIterator

public ReadOnlyIterator(Iterator<E> iterator)
The constructor.

Parameters:
iterator - is the Iterator to adapt.
Method Detail

hasNext

public boolean hasNext()

Specified by:
hasNext in interface Iterator<E>

next

public E next()

Specified by:
next in interface Iterator<E>

remove

public void remove()
            throws UnsupportedOperationException
This method will always throw an exception.

Specified by:
remove in interface Iterator<E>
Throws:
UnsupportedOperationException - whenever this method is called.
See Also:
Iterator.remove()


Copyright © 2001-2010 mmm-Team. All Rights Reserved.