| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
package net.sf.saxon.tree.iter; |
| 9 |
|
| 10 |
import net.sf.saxon.om.Item; |
| 11 |
import net.sf.saxon.om.SequenceIterator; |
| 12 |
import net.sf.saxon.trans.XPathException; |
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
public class LookaheadIteratorImpl implements LookaheadIterator { |
| 19 |
|
| 20 |
private SequenceIterator base; |
| 21 |
private Item next; |
| 22 |
|
| 23 |
private LookaheadIteratorImpl( SequenceIterator base) throws XPathException { |
| 24 |
this.base = base; |
| 25 |
next = base.next(); |
| 26 |
} |
| 27 |
|
| 28 |
|
| 29 |
public static LookaheadIterator makeLookaheadIterator( SequenceIterator base) throws XPathException { |
| 30 |
if ((base.getProperties() & SequenceIterator.LOOKAHEAD) != 0) { |
| 31 |
return (LookaheadIterator) base; |
| 32 |
} else { |
| 33 |
return new LookaheadIteratorImpl(base); |
| 34 |
} |
| 35 |
} |
| 36 |
|
| 37 |
public boolean hasNext() { |
| 38 |
return next != null; |
| 39 |
} |
| 40 |
|
| 41 |
|
| 42 |
public Item next() throws XPathException { |
| 43 |
Item current = next; |
| 44 |
if (next != null) { |
| 45 |
next = base.next(); |
| 46 |
} |
| 47 |
return current; |
| 48 |
} |
| 49 |
|
| 50 |
public void close() { |
| 51 |
base.close(); |
| 52 |
} |
| 53 |
|
| 54 |
public int getProperties() { |
| 55 |
return LOOKAHEAD; |
| 56 |
} |
| 57 |
} |
| 58 |
|