1 18 package org.apache.beehive.netui.util.iterator; 19 20 import java.util.Iterator ; 21 import java.util.Map ; 22 import java.util.NoSuchElementException ; 23 24 import org.apache.beehive.netui.util.Bundle; 25 26 30 public class MapIterator 31 implements Iterator { 32 33 36 private Iterator _mapIterator = null; 37 38 42 public MapIterator(Map map) { 43 if(map == null) 44 return; 45 46 _mapIterator = map.values().iterator(); 47 } 48 49 54 public boolean hasNext() { 55 if(_mapIterator == null) 56 return false; 57 else return _mapIterator.hasNext(); 58 } 59 60 66 public Object next() { 67 if(_mapIterator == null) 68 throw new NoSuchElementException (Bundle.getErrorString("IteratorFactory_Iterator_noSuchElement")); 69 else return _mapIterator.next(); 70 } 71 72 75 public void remove() { 76 if(_mapIterator == null) 77 throw new UnsupportedOperationException (Bundle.getErrorString("IteratorFactory_Iterator_removeUnsupported", new Object []{this.getClass().getName()})); 78 else _mapIterator.remove(); 79 } 80 } 81 | Popular Tags |