51 lines
1.4 KiB
Java
51 lines
1.4 KiB
Java
|
|
/*
|
||
|
|
* Copyright (c) 2005,2008 Declarative Engineering LLC.
|
||
|
|
* All rights reserved. This program and the accompanying materials
|
||
|
|
* are made available under the terms of the Declarative Engineering LLC
|
||
|
|
* verson 1 which accompanies this distribution, and is available at
|
||
|
|
* http://declarativeengineering.com/legal/DE_Developer_License_v1.txt
|
||
|
|
*/
|
||
|
|
package com.common.util;
|
||
|
|
|
||
|
|
/*
|
||
|
|
* A simple empty iterator singleton.
|
||
|
|
*/
|
||
|
|
public final class EmptyIterator implements IIterator {
|
||
|
|
/** The one and only empty iterator object. */
|
||
|
|
private static EmptyIterator singleton = new EmptyIterator();
|
||
|
|
/**
|
||
|
|
* Gets the single instance of this iterator.
|
||
|
|
* @return The one and only empty iterator object.
|
||
|
|
*/
|
||
|
|
public static IIterator getSingleton() {
|
||
|
|
return singleton;
|
||
|
|
}//getSingleton()//
|
||
|
|
/**
|
||
|
|
* EmptyIterator constructor.
|
||
|
|
*/
|
||
|
|
private EmptyIterator() {
|
||
|
|
}//EmptyIterator()//
|
||
|
|
/* (non-Javadoc)
|
||
|
|
* @see com.common.util.IIterator#hasNext()
|
||
|
|
*/
|
||
|
|
public boolean hasNext() {
|
||
|
|
return false;
|
||
|
|
}//hasNext()//
|
||
|
|
/* (non-Javadoc)
|
||
|
|
* @see com.common.util.IIterator#next()
|
||
|
|
*/
|
||
|
|
public Object next() {
|
||
|
|
throw new IndexOutOfBoundsException("Empty iterator.");
|
||
|
|
}//next()//
|
||
|
|
/* (non-Javadoc)
|
||
|
|
* @see com.common.util.IIterator#remove()
|
||
|
|
*/
|
||
|
|
public boolean remove() {
|
||
|
|
return false;
|
||
|
|
}//remove()//
|
||
|
|
/* (non-Javadoc)
|
||
|
|
* @see com.common.util.IIterator#resetToFront()
|
||
|
|
*/
|
||
|
|
public void resetToFront() {
|
||
|
|
}//resetToFront()//
|
||
|
|
}//EmptyIterator//
|