1 18 package org.apache.beehive.netui.util.iterator; 19 20 import java.util.Enumeration ; 21 import java.util.Iterator ; 22 import java.util.NoSuchElementException ; 23 24 import org.apache.beehive.netui.util.Bundle; 25 26 29 public class EnumerationIterator 30 implements Iterator { 31 32 private Enumeration _enum = null; 33 34 public EnumerationIterator(Enumeration e) { 35 _enum = e; 36 } 37 38 public boolean hasNext() { 39 if(_enum == null) 40 return false; 41 else return _enum.hasMoreElements(); 42 } 43 44 public Object next() { 45 if(_enum == null || hasNext() == false) 46 throw new NoSuchElementException (Bundle.getErrorString("IteratorFactory_Iterator_noSuchElement")); 47 else return _enum.nextElement(); 48 } 49 50 public void remove() { 51 throw new UnsupportedOperationException (Bundle.getErrorString("IteratorFactory_Iterator_removeUnsupported", 52 new Object []{this.getClass().getName()})); 53 } 54 } 55 | Popular Tags |