1 package net.sf.saxon.expr; 2 3 import net.sf.saxon.om.SequenceIterator; 4 import net.sf.saxon.om.Item; 5 import net.sf.saxon.trans.XPathException; 6 7 10 11 public class AppendIterator implements SequenceIterator { 12 13 private SequenceIterator first; 14 private Expression second; 15 private XPathContext context; 16 private SequenceIterator currentIterator; 17 private int position = 0; 18 19 27 28 public AppendIterator(SequenceIterator first, Expression second, XPathContext context) { 29 this.first = first; 30 this.second = second; 31 this.context = context; 32 this.currentIterator = first; 33 } 34 35 public Item next() throws XPathException { 36 Item n = currentIterator.next(); 37 if (n == null && currentIterator==first) { 38 currentIterator = second.iterate(context); 39 n = currentIterator.next(); 40 } 41 if (n == null) { 42 position = -1; 43 } else { 44 position++; 45 } 46 return n; 47 } 48 49 public Item current() { 50 return currentIterator.current(); 51 } 52 53 public int position() { 54 return position; 55 } 56 57 public SequenceIterator getAnother() throws XPathException { 58 return new AppendIterator(first.getAnother(), second, context); 59 } 60 61 70 71 public int getProperties() { 72 return 0; 73 } 74 } 75 76 | Popular Tags |