com.ccg.util
Class ArrayEnumeration

java.lang.Object
  extended by com.ccg.util.ArrayEnumeration
All Implemented Interfaces:
Enumeration

public final class ArrayEnumeration
extends Object
implements Enumeration

Convert any array of objects into an Enumeration.

Java probably has this functionality somewhere (I just couldn't seem to find it). This simple class puts the wrapper around an array of objects to make the array behave like a standard Java Enumeration.

Some notes:

Since:
1.0
Version:
$Revision: 1.4 $
Author:
$Author: pkb $
See Also:
EmptyEnumeration

Constructor Summary
ArrayEnumeration(Object[] array)
          Contruct the array enumeration.
 
Method Summary
 boolean hasMoreElements()
          Determine if there are more elements.
 Object nextElement()
          Get next element in Enumeration This returns the next item in the Enumeration.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ArrayEnumeration

public ArrayEnumeration(Object[] array)
Contruct the array enumeration. This is the method used to construct an array enumeration, you simply pass the array of elements which you want to iterate over. Currently this enumeration keeps a light copy of the array passed (hence you shouldn't modify the array passed until you are done with the enumeration).

Parameters:
array - Array of objects to appear when one enumerates. You may pass null.
Since:
1.0
Method Detail

hasMoreElements

public boolean hasMoreElements()
Determine if there are more elements. This routine indicates whether the Enumeration has more elements left in it to enumerate over.

Specified by:
hasMoreElements in interface Enumeration
Returns:
true if there are any elements left, false if not.
See Also:
Enumeration

nextElement

public Object nextElement()
Get next element in Enumeration This returns the next item in the Enumeration. Only call this if hasMoreElements() returns true.

Specified by:
nextElement in interface Enumeration
Returns:
Returns next element in enumeration - will throw an exception on you if you attempt to fetch the next element once the "hasMoreElements()" returns false.
See Also:
Enumeration


Copyright 1998-1998-2006 null. All Rights Reserved.