net.sf.composite.util
Class ArrayIterator

java.lang.Object
  extended by net.sf.composite.util.ArrayIterator
All Implemented Interfaces:
java.util.Iterator

public class ArrayIterator
extends java.lang.Object
implements java.util.Iterator

An iterator over the contents of an array. This implementation only allows an array to be iterated over once, but a reset method could easily be added to allow for the array to be iterated over multiple times or for another array to use the same ArrayIterator instance as an iterator for it.

Since:
Dec 5, 2004
Author:
Matt Sgarlata

Constructor Summary
ArrayIterator()
           
ArrayIterator(java.lang.Object array)
           
 
Method Summary
 java.lang.Object getArray()
           
 boolean hasNext()
           
 java.lang.Object next()
           
 void remove()
           
 void setArray(java.lang.Object array)
          Sets the array to be iterated over
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ArrayIterator

public ArrayIterator()

ArrayIterator

public ArrayIterator(java.lang.Object array)
Method Detail

hasNext

public boolean hasNext()
Specified by:
hasNext in interface java.util.Iterator

next

public java.lang.Object next()
Specified by:
next in interface java.util.Iterator

remove

public void remove()
Specified by:
remove in interface java.util.Iterator

getArray

public java.lang.Object getArray()
Returns:
Returns the array.

setArray

public void setArray(java.lang.Object array)
Sets the array to be iterated over

Parameters:
array - The array to set.
Throws:
java.lang.IllegalStateException - if this method is called after a call has been made to next()
java.lang.IllegalArgumentException - if the supplied object is not an array


Copyright © 2005-2008.