Oracle

com.compoze.util
Class PeekableIterator

java.lang.Object
  extended by com.compoze.util.PeekableIterator
All Implemented Interfaces:
java.io.Serializable, java.util.Iterator

public class PeekableIterator
extends java.lang.Object
implements java.util.Iterator, java.io.Serializable

This class implements an iterator that is "peekable", or one whose next element may be viewed without considering the next element in the iteration.

See Also:
Serialized Form

Constructor Summary
PeekableIterator(java.util.Iterator it)
          Constructor.
 
Method Summary
 boolean hasNext()
          Return true if the iteration has more elements.
 java.lang.Object next()
          Return the next element in the iteration.
 java.lang.Object peek()
          Peek at the next element without considering it the next element in the iteration.
 void remove()
          Remove the last element returned by the iterator (not implemented).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PeekableIterator

public PeekableIterator(java.util.Iterator it)
Constructor.

Method Detail

hasNext

public boolean hasNext()
Return true if the iteration has more elements.

Specified by:
hasNext in interface java.util.Iterator
Returns:
true if the iteration has more elements

next

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

Specified by:
next in interface java.util.Iterator
Returns:
the next element in the iteration

peek

public java.lang.Object peek()
Peek at the next element without considering it the next element in the iteration.

Returns:
the next element in the iteration

remove

public void remove()
Remove the last element returned by the iterator (not implemented).

Specified by:
remove in interface java.util.Iterator
Throws:
java.lang.UnsupportedOperationException - if the underlying iterator does not implement this method

Oracle

Copyright ©1999-2008 Oracle All rights reserved.