DESY ACOP Beans Home

com.cosylab.util
Class ArrayEnumeration

java.lang.Object
  extended by com.cosylab.util.ArrayEnumeration
All Implemented Interfaces:
java.util.Enumeration, java.util.Iterator

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

A simple implementation of both the java.util.Enumeration and java.util.Iterator that iterates over the array of type Object[]. Removal of elements is not permitted. The iteration is not thread safe.

Version:
$id$
Author:
Gasper Tkacik

Field Summary
protected  java.lang.Object[] array
          The array storing the data over which this iterator will iterate.
 
Constructor Summary
ArrayEnumeration(java.lang.Object[] array)
          Creates a new instance of array enumeration, given the array over which this instance will iterate.
 
Method Summary
 boolean hasMoreElements()
          Returns true iff calling nextElement() will return a valid value.
 boolean hasNext()
          A shorthand for hasMoreElements()
 java.lang.Object next()
          A shorthand for nextElement().
 java.lang.Object nextElement()
          Returns the next element in the array.
 void remove()
          Not implemented.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

array

protected java.lang.Object[] array
The array storing the data over which this iterator will iterate.

Constructor Detail

ArrayEnumeration

public ArrayEnumeration(java.lang.Object[] array)
Creates a new instance of array enumeration, given the array over which this instance will iterate.

Parameters:
array - array of iteration, non-null
Method Detail

hasMoreElements

public boolean hasMoreElements()
Returns true iff calling nextElement() will return a valid value.

Specified by:
hasMoreElements in interface java.util.Enumeration
Returns:
true if there are more elements to be iterated over in the array

nextElement

public java.lang.Object nextElement()
Returns the next element in the array. If this method is called after the end of the array has been reached (when hasMoreElements() returns false, an array index out of bounds exception will be thrown.

Specified by:
nextElement in interface java.util.Enumeration
Returns:
the next object in the array, can be null

hasNext

public boolean hasNext()
A shorthand for hasMoreElements()

Specified by:
hasNext in interface java.util.Iterator
Returns:
true iff this array has more elements to be iterated over

next

public java.lang.Object next()
A shorthand for nextElement().

Specified by:
next in interface java.util.Iterator
Returns:
the next element in the array

remove

public void remove()
Not implemented.

Specified by:
remove in interface java.util.Iterator
Throws:
java.lang.UnsupportedOperationException - always


Copyright © 2010. All Rights Reserved.