1 30 package com.hp.hpl.jena.util.iterator; 32 import java.util.Iterator ; 33 import java.lang.reflect.Array ; 34 import java.util.NoSuchElementException ; 35 36 40 public class ArrayIterator implements Iterator { 41 private int i; 42 private Object a; 43 47 public ArrayIterator(Object array) { 48 i = 0; 49 a = array; 50 if (!a.getClass().isArray()) 51 throw new ArrayStoreException (); 52 } 53 public boolean hasNext() { 54 return i<Array.getLength(a); 55 } 56 public Object next() throws NoSuchElementException { 57 try { 58 return Array.get(a,i++); 59 } 60 catch (IndexOutOfBoundsException e) { 61 throw new NoSuchElementException (); 62 } 63 } 64 68 public void remove() { 69 70 throw new UnsupportedOperationException (); 71 } 72 } | Popular Tags |