iaik.utils
Class ArrayEnumeration

java.lang.Object
  |
  +--iaik.utils.ArrayEnumeration

public class ArrayEnumeration
extends java.lang.Object
implements java.util.Enumeration

This class implements a simple Enumeration over an array.

When creating an ArrayEnumeration from an array of objects you optionally may specify the number of elements of the array that shall admit to the ArrayEnumeration, e.g.:

 SomeObject[] obj = ...;
 ArrayEnumeration arrayEnum = new ArrayEnumeration(obj, 2);
 
will create an ArrayEnumaeration of the first two elements of the given array of objects.

For getting the elements of an ArrayEnumeration use the hasMoreElements and nextElement methods, as already familiarly from the java.util.Enumeration, e.g.:

 
 for (; arrEnum.hasMoreElements() ; ) {
    System.out.println(arrayEnum.nextElement()); 
 }
 


Constructor Summary
ArrayEnumeration(java.lang.Object[] array)
          Creates a new ArrayEnumeration from all the elements included in the given array of objects.
ArrayEnumeration(java.lang.Object[] array, int length)
          Creates a new ArrayEnumeration from the given number of elements of the given array of objects.
 
Method Summary
 boolean hasMoreElements()
          Checks if there are more elements in this ArrayEnumeration.
 java.lang.Object nextElement()
          Returns the next element of this ArrayEnumeration.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ArrayEnumeration

public ArrayEnumeration(java.lang.Object[] array)
Creates a new ArrayEnumeration from all the elements included in the given array of objects.
Parameters:
array - the array

ArrayEnumeration

public ArrayEnumeration(java.lang.Object[] array,
                        int length)
Creates a new ArrayEnumeration from the given number of elements of the given array of objects.

The first length elements of the given array will admit to the new ArrayEnumeration.

Parameters:
array - the array
Method Detail

hasMoreElements

public boolean hasMoreElements()
Checks if there are more elements in this ArrayEnumeration.
Specified by:
hasMoreElements in interface java.util.Enumeration
Returns:
true if there are more elements, false if not

nextElement

public java.lang.Object nextElement()
Returns the next element of this ArrayEnumeration.
Specified by:
nextElement in interface java.util.Enumeration
Returns:
the next element.