Jive Forums API (5.5.20.2-oracle) Developer Javadocs

com.jivesoftware.forum.nntp.spi
Class PeekIterator

java.lang.Object
  extended by com.jivesoftware.forum.nntp.spi.PeekIterator
All Implemented Interfaces:
java.util.Iterator
Direct Known Subclasses:
DotIterator, FNameFilterIterator, MimeBodyPartIterator, UUBeginIterator, UUEndIterator

public class PeekIterator
extends java.lang.Object
implements java.util.Iterator

A simple iterator wrapper that allows a caller to peek into the next element without actually iterating over it.


Constructor Summary
PeekIterator(java.util.Iterator itr)
          Wraps the given iterator in this one to make it peek()'able.
PeekIterator(java.util.Iterator itr, java.lang.Object firstItem)
          Wraps the given iterator in this one to make it peek()'able and adding the given line as the first line to peek.
 
Method Summary
 boolean hasNext()
          Returns true if there are more elements that can be returned from calls to next() or peek().
 java.lang.Object next()
          Returns the next element and moves the iterator forward.
 java.lang.Object peek()
          Peeks into the next element without iterating.
 void remove()
          Unsupported operation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PeekIterator

public PeekIterator(java.util.Iterator itr)
Wraps the given iterator in this one to make it peek()'able.

Parameters:
itr - The iterator to wrap

PeekIterator

public PeekIterator(java.util.Iterator itr,
                    java.lang.Object firstItem)
Wraps the given iterator in this one to make it peek()'able and adding the given line as the first line to peek.

Parameters:
itr - the iterator to wrap
firstItem - the first line to peek
Method Detail

peek

public java.lang.Object peek()
Peeks into the next element without iterating. Essentially the same as the normal Iterator.next() method minus the side effect of moving the iterator.

Returns:
The next element of the iterator

remove

public void remove()
            throws java.lang.UnsupportedOperationException
Unsupported operation.

Specified by:
remove in interface java.util.Iterator
Throws:
java.lang.UnsupportedOperationException - If the underlying iterator doesn't support remove()

hasNext

public boolean hasNext()
Returns true if there are more elements that can be returned from calls to next() or peek().

Specified by:
hasNext in interface java.util.Iterator
Returns:
True if there are more elements to iterate over

next

public java.lang.Object next()
Returns the next element and moves the iterator forward.

Specified by:
next in interface java.util.Iterator
Returns:
The next element of the iterator

Jive Forums Project Page

Copyright © 1999-2006 Jive Software.