1 package net.sf.saxon.expr; 2 3 import java.util.Iterator ; 4 import java.util.NoSuchElementException ; 5 6 9 public class PairIterator implements Iterator { 10 11 private Object one; 12 private Object two; 13 private int pos = 0; 14 15 public PairIterator(Object one, Object two) { 16 this.one = one; 17 this.two = two; 18 } 19 20 27 28 public boolean hasNext() { 29 return pos<2; 30 } 31 32 38 public Object next() { 39 switch (pos++) { 40 case 0: return one; 41 case 1: return two; 42 default: throw new NoSuchElementException (); 43 } 44 } 45 46 62 public void remove() { 63 throw new UnsupportedOperationException (); 64 } 65 } 66 67 68 | Popular Tags |