Empty Enumeration : Enumerator « Collections Data Structure « Java






Empty Enumeration

   

/*
 * Copyright Javelin Software, All rights reserved.
 */


import java.util.*;

/**
 * An EmptyEnumeration.
 *
 * @author Robin Sharp
 */

public class EmptyEnumeration implements Enumeration 
{
    public static Enumeration getInstance()
    {
        return enumeration;
    }
    
    /**
     * @return false;
     */
     public boolean hasMoreElements()
     {
        return false;
     }
     
    /**
     * @return null
     */
     public Object nextElement()
     {
        return null;
     }
     
     protected static Enumeration enumeration = new EmptyEnumeration();
}

   
    
    
  








Related examples in the same category

1.Wrapping an Iterator around an Enumeration
2.A GOF Adapter to make instances of old Enumeration interface behave like new Iterator interface
3.A more robust enumeration systemA more robust enumeration system
4.ListOfFiles implements Enumeration
5.Treat an Enumeration as an Iterable
6.Support for breadth-first enumerating.
7.Single Item Enumeration
8.Enumeration interface which enumerates the items of an arrayEnumeration interface which enumerates the items of an array
9.Filtering Enumeration
10.An enumeration that iterates over an array.An enumeration that iterates over an array.
11.Concatenates the content of two enumerations into one.
12.Removes all nulls from the input enumeration.
13.Filters some elements out from the input enumeration.
14.For each element of the input enumeration asks the Processor to provide a replacement