1 11 package org.eclipse.core.internal.utils; 12 13 import java.util.Enumeration ; 14 import java.util.NoSuchElementException ; 15 16 19 20 public class ArrayEnumeration implements Enumeration { 21 int index; 22 int lastElement; 23 Object [] elements; 24 25 28 public ArrayEnumeration(Object [] elements) { 29 this(elements, 0, elements.length - 1); 30 } 31 32 35 public ArrayEnumeration(Object [] elements, int firstElement, int lastElement) { 36 super(); 37 this.elements = elements; 38 index = firstElement; 39 this.lastElement = lastElement; 40 } 41 42 45 public boolean hasMoreElements() { 46 return elements != null && index <= lastElement; 47 } 48 49 53 public Object nextElement() throws NoSuchElementException { 54 if (!hasMoreElements()) 55 throw new NoSuchElementException (); 56 return elements[index++]; 57 } 58 } 59 | Popular Tags |