1 16 package org.apache.commons.jxpath.ri.axes; 17 18 import org.apache.commons.jxpath.NodeSet; 19 import org.apache.commons.jxpath.ri.EvalContext; 20 import org.apache.commons.jxpath.ri.model.NodePointer; 21 22 28 public class NodeSetContext extends EvalContext { 29 private boolean startedSet = false; 30 private NodeSet nodeSet; 31 32 public NodeSetContext(EvalContext parentContext, NodeSet nodeSet) { 33 super(parentContext); 34 this.nodeSet = nodeSet; 35 } 36 37 public NodeSet getNodeSet() { 38 return nodeSet; 39 } 40 41 public NodePointer getCurrentNodePointer() { 42 if (position == 0) { 43 if (!setPosition(1)) { 44 return null; 45 } 46 } 47 return (NodePointer) nodeSet.getPointers().get(position - 1); 48 } 49 50 public boolean setPosition(int position) { 51 super.setPosition(position); 52 return position >= 1 && position <= nodeSet.getPointers().size(); 53 } 54 55 public boolean nextSet() { 56 if (startedSet) { 57 return false; 58 } 59 startedSet = true; 60 return true; 61 } 62 63 public boolean nextNode() { 64 return setPosition(position + 1); 65 } 66 } | Popular Tags |