1 package net.sf.saxon.om; 2 3 8 9 public class PrependIterator implements AxisIterator { 10 11 NodeInfo start; 12 AxisIterator base; 13 int position = 0; 14 15 public PrependIterator(NodeInfo start, AxisIterator base) { 16 this.start = start; 17 this.base = base; 18 } 19 20 25 26 public Item next() { 27 if (position == 0) { 28 position = 1; 29 return start; 30 } 31 Item n = base.next(); 32 if (n == null) { 33 position = -1; 34 } else { 35 position++; 36 } 37 return n; 38 } 39 40 46 47 public Item current() { 48 if (position() == 1) { 49 return start; 50 } else if (position < 1) { 51 return null; 52 } else { 53 return base.current(); 54 } 55 } 56 57 63 64 public int position() { 65 return position; 66 } 67 68 74 75 public SequenceIterator getAnother() { 76 return new PrependIterator(start, base); 77 } 78 79 88 89 public int getProperties() { 90 return 0; 91 } 92 93 94 } 95 96 | Popular Tags |