Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

gnu.java.util
Class EmptyEnumeration  view EmptyEnumeration download EmptyEnumeration.java

java.lang.Object
  extended bygnu.java.util.EmptyEnumeration
All Implemented Interfaces:
java.util.Enumeration, java.io.Serializable

public final class EmptyEnumeration
extends java.lang.Object
implements java.util.Enumeration, java.io.Serializable

This is a helper class that produces an empty Enumerations. There is only one instance of this class that can be used whenever one needs a non-null but empty enumeration. Using this class prevents multiple small objects and inner classes. getInstance() returns the only instance of this class. It can be shared by multiple objects and threads.


Field Summary
private static EmptyEnumeration instance
          The only instance of this class
 
Constructor Summary
private EmptyEnumeration()
          Private constructor that creates a new empty Enumeration.
 
Method Summary
static EmptyEnumeration getInstance()
          Returns the only instance of this class.
 boolean hasMoreElements()
          Returns false, since there are no elements.
 java.lang.Object nextElement()
          Always throws NoSuchElementException, since it is empty.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

instance

private static final EmptyEnumeration instance
The only instance of this class

Constructor Detail

EmptyEnumeration

private EmptyEnumeration()
Private constructor that creates a new empty Enumeration.

Method Detail

getInstance

public static EmptyEnumeration getInstance()
Returns the only instance of this class. It can be shared by multiple objects and threads.


hasMoreElements

public boolean hasMoreElements()
Returns false, since there are no elements.

Specified by:
hasMoreElements in interface java.util.Enumeration

nextElement

public java.lang.Object nextElement()
Always throws NoSuchElementException, since it is empty.

Specified by:
nextElement in interface java.util.Enumeration