1 package net.sf.saxon.tinytree; 2 import net.sf.saxon.om.AxisIteratorImpl; 3 import net.sf.saxon.om.Item; 4 import net.sf.saxon.om.SequenceIterator; 5 import net.sf.saxon.pattern.NodeTest; 6 7 12 13 final class PrecedingSiblingEnumeration extends AxisIteratorImpl { 14 15 private TinyTree document; 16 private TinyNodeImpl startNode; 17 private int nextNodeNr; 18 private NodeTest test; 19 private TinyNodeImpl parentNode; 20 21 PrecedingSiblingEnumeration(TinyTree doc, TinyNodeImpl node, NodeTest nodeTest) { 22 document = doc; 23 document.ensurePriorIndex(); 24 test = nodeTest; 25 startNode = node; 26 nextNodeNr = node.nodeNr; 27 parentNode = node.parent; } 29 30 public Item next() { 31 while (true) { 35 nextNodeNr = document.prior[nextNodeNr]; 36 if (nextNodeNr < 0) { 37 current = null; 38 position = -1; 39 return null; 40 } 41 if (test.matches(document, nextNodeNr)) { 42 position++; 43 current = document.getNode(nextNodeNr); 44 ((TinyNodeImpl)current).setParentNode(parentNode); 45 return current; 46 }; 47 } 48 } 49 50 53 54 public SequenceIterator getAnother() { 55 return new PrecedingSiblingEnumeration(document, startNode, test); 56 } 57 58 } 59 60 61 | Popular Tags |