1 61 62 63 package org.jaxen.util; 64 65 import java.util.Iterator ; 66 import java.util.NoSuchElementException ; 67 68 public class SingleObjectIterator implements Iterator 69 { 70 private Object object; 71 private boolean seen; 72 73 public SingleObjectIterator(Object object) 74 { 75 this.object = object; 76 this.seen = false; 77 } 78 79 public boolean hasNext() 80 { 81 return ! this.seen; 82 } 83 84 public Object next() 85 { 86 if ( hasNext() ) 87 { 88 this.seen = true; 89 return this.object; 90 } 91 92 throw new NoSuchElementException (); 93 } 94 95 public void remove() 96 { 97 throw new UnsupportedOperationException (); 98 } 99 } 100 | Popular Tags |