All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.codehaus.stax2.ri.EmptyIterator Maven / Gradle / Ivy

Go to download

Stax2 API is an extension to basic Stax 1.0 API that adds significant new functionality, such as full-featured bi-direction validation interface and high-performance Typed Access API.

There is a newer version: 4.2.2
Show newest version
package org.codehaus.stax2.ri;

import java.util.Iterator;

/**
 * Simple implementation of "null iterator", iterator that has nothing to
 * iterate over.
 */
public final class EmptyIterator
    implements Iterator
{
    final static Iterator sInstance = new EmptyIterator();

    private EmptyIterator() { }

    @SuppressWarnings("unchecked")
    public static  Iterator getInstance() { return (Iterator) sInstance; }
    
    public boolean hasNext() { return false; }
    
    public Object next() {
        throw new java.util.NoSuchElementException();
    }
    
    public void remove()
    {
        /* The reason we do this is that we know for a fact that
         * it can not have been moved
         */
        throw new IllegalStateException();
    }
}