1 package com.icl.saxon.tree; 2 import com.icl.saxon.pattern.NodeTest; 3 4 final class PrecedingEnumeration extends TreeEnumeration { 5 6 NodeImpl nextAncestor; 7 8 public PrecedingEnumeration(NodeImpl node, NodeTest nodeTest) { 9 super(node, nodeTest); 10 11 nextAncestor = (NodeImpl)node.getParent(); 13 advance(); 14 } 15 16 17 20 21 protected boolean conforms(NodeImpl node) { 22 if (node!=null) { 25 if (node.isSameNode(nextAncestor)) { 26 nextAncestor = (NodeImpl)nextAncestor.getParent(); 27 return false; 28 } 29 } 30 return super.conforms(node); 31 } 32 33 protected void step() { 34 next = next.getPreviousInDocument(); 35 } 36 37 40 41 public int getLastPosition() { 42 if (last>=0) return last; 43 PrecedingEnumeration enum = 44 new PrecedingEnumeration(start, nodeTest); 45 return enum.count(); 46 } 47 } 48 49 50 51 52 | Popular Tags |