1 package com.icl.saxon.tree; 2 import com.icl.saxon.om.NodeInfo; 3 import com.icl.saxon.pattern.NodeTest; 4 5 final class FollowingEnumeration extends TreeEnumeration { 6 7 private NodeImpl root; 8 9 public FollowingEnumeration(NodeImpl node, NodeTest nodeTest) { 10 super(node, nodeTest); 11 root = (DocumentImpl)node.getDocumentRoot(); 12 short type = node.getNodeType(); 14 if (type==NodeInfo.ATTRIBUTE || type==NodeInfo.NAMESPACE) { 15 next = ((NodeImpl)node.getParentNode()).getNextInDocument(root); 16 } else { 17 do { 18 next = (NodeImpl)node.getNextSibling(); 19 if (next==null) node = (NodeImpl)node.getParentNode(); 20 } while (next==null && node!=null); 21 } 22 while (!conforms(next)) { 23 step(); 24 } 25 } 26 27 protected void step() { 28 next = next.getNextInDocument(root); 29 } 30 31 public boolean isSorted() { 32 return true; 33 } 34 35 38 39 public int getLastPosition() { 40 if (last>=0) return last; 41 FollowingEnumeration enum = 42 new FollowingEnumeration(start, nodeTest); 43 return enum.count(); 44 } 45 } 46 47 48 | Popular Tags |