1 18 package org.apache.beehive.netui.util.iterator; 19 20 import java.util.Iterator ; 21 import java.util.NoSuchElementException ; 22 23 import org.apache.beehive.netui.util.Bundle; 24 25 27 public class AtomicObjectIterator 28 implements Iterator { 29 30 33 private Object _object; 34 35 38 private boolean _nextCalled = false; 39 40 AtomicObjectIterator(Object object) { 41 _object = object; 42 } 43 44 public boolean hasNext() { 45 if(_nextCalled || _object == null) 46 return false; 47 else return true; 48 } 49 50 public Object next() { 51 if(!_nextCalled && _object != null) { 52 _nextCalled = true; 53 return _object; 54 } 55 else throw new NoSuchElementException (Bundle.getErrorString("IteratorFactory_Iterator_noSuchElement")); 56 } 57 58 public void remove() { 59 throw new UnsupportedOperationException (Bundle.getErrorString("IteratorFactory_Iterator_removeUnsupported", new Object []{this.getClass().getName()})); 60 } 61 } 62 | Popular Tags |