org.jaxen.util

Class SingleObjectIterator

Implemented Interfaces:
Iterator
Known Direct Subclasses:
SelfAxisIterator

public class SingleObjectIterator
extends java.lang.Object
implements 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 Object
object
private boolean
seen

Constructor Summary

SingleObjectIterator(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.
Object
next()
Returns the single element in this iterator if it has not yet been seen.
void
remove()
This operation is not supported.

Field Details

object

private Object object

seen

private boolean seen

Constructor Details

SingleObjectIterator

public SingleObjectIterator(Object object)
Creates a new single object iterator.
Parameters:
object - the object to iterate over

Method Details

hasNext

public boolean hasNext()
Returns true if this iterator's element has not yet been seen; false if it has.
Returns:
true if this iterator has another element; false if it doesn't
See Also:
java.util.Iterator.hasNext()

next

public Object next()
Returns the single element in this iterator if it has not yet been seen.
Returns:
the next element in this iterator
See Also:
java.util.Iterator.next()

remove

public void remove()
This operation is not supported.