1 7 8 package org.dom4j.tree; 9 10 import java.util.Iterator ; 11 12 21 public class SingleIterator implements Iterator { 22 private boolean first = true; 23 24 private Object object; 25 26 public SingleIterator(Object object) { 27 this.object = object; 28 } 29 30 public boolean hasNext() { 31 return first; 32 } 33 34 public Object next() { 35 Object answer = object; 36 object = null; 37 first = false; 38 39 return answer; 40 } 41 42 public void remove() { 43 throw new UnsupportedOperationException ("remove() is not supported by " 44 + "this iterator"); 45 } 46 } 47 48 84 | Popular Tags |