1 22 package org.jboss.util.collection; 23 24 import java.util.Iterator ; 25 import java.util.NoSuchElementException ; 26 27 import java.io.Serializable ; 28 29 import org.jboss.util.NullArgumentException; 30 31 37 public class ArrayIterator 38 implements Iterator , Serializable , Cloneable 39 { 40 41 protected final Object [] array; 42 43 44 protected int index; 45 46 51 public ArrayIterator(final Object [] array) { 52 if (array == null) 53 throw new NullArgumentException("array"); 54 55 this.array = array; 56 } 57 58 63 public boolean hasNext() { 64 return index < array.length; 65 } 66 67 74 public Object next() { 75 if (! hasNext()) 76 throw new NoSuchElementException (); 77 78 return array[index++]; 79 } 80 81 86 public void remove() { 87 throw new UnsupportedOperationException (); 88 } 89 90 95 public Object clone() { 96 try { 97 return super.clone(); 98 } 99 catch (CloneNotSupportedException e) { 100 throw new InternalError (); 101 } 102 } 103 } 104 | Popular Tags |