org.jaxen.util
Class SingleObjectIterator

java.lang.Object
  extended by org.jaxen.util.SingleObjectIterator
All Implemented Interfaces:
java.util.Iterator
Direct Known Subclasses:
SelfAxisIterator

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

Simple utility class that wraps an iterator around one object. This is a little more efficent than creating a one-object list.


Field Summary
private  java.lang.Object object
           
private  boolean seen
           
 
Constructor Summary
SingleObjectIterator(java.lang.Object object)
          Creates a new single object iterator.
 
Method Summary
 boolean hasNext()
          Returns true if this iterator's element has not yet been seen; false if it has.
 java.lang.Object next()
          Returns the single element in this iterator if it has not yet been seen.
 void remove()
          This operation is not supported.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

object

private java.lang.Object object

seen

private boolean seen
Constructor Detail

SingleObjectIterator

public SingleObjectIterator(java.lang.Object object)
Creates a new single object iterator.

Parameters:
object - the object to iterate over
Method Detail

hasNext

public boolean hasNext()
Returns true if this iterator's element has not yet been seen; false if it has.

Specified by:
hasNext in interface java.util.Iterator
Returns:
true if this iterator has another element; false if it doesn't
See Also:
Iterator.hasNext()

next

public java.lang.Object next()
Returns the single element in this iterator if it has not yet been seen.

Specified by:
next in interface java.util.Iterator
Returns:
the next element in this iterator
Throws:
java.util.NoSuchElementException - if the element has already been seen
See Also:
Iterator.next()

remove

public void remove()
This operation is not supported.

Specified by:
remove in interface java.util.Iterator
Throws:
java.lang.UnsupportedOperationException - always