1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.jxpath.ri.axes;
18
19 import org.apache.commons.jxpath.NodeSet;
20 import org.apache.commons.jxpath.ri.EvalContext;
21 import org.apache.commons.jxpath.ri.model.NodePointer;
22
23
24
25
26
27
28
29 public class NodeSetContext extends EvalContext {
30 private boolean startedSet = false;
31 private NodeSet nodeSet;
32
33
34
35
36
37
38 public NodeSetContext(EvalContext parentContext, NodeSet nodeSet) {
39 super(parentContext);
40 this.nodeSet = nodeSet;
41 }
42
43 public NodeSet getNodeSet() {
44 return nodeSet;
45 }
46
47 public NodePointer getCurrentNodePointer() {
48 if (position == 0 && !setPosition(1)) {
49 return null;
50 }
51 return (NodePointer) nodeSet.getPointers().get(position - 1);
52 }
53
54 public boolean setPosition(int position) {
55 super.setPosition(position);
56 return position >= 1 && position <= nodeSet.getPointers().size();
57 }
58
59 public boolean nextSet() {
60 if (startedSet) {
61 return false;
62 }
63 startedSet = true;
64 return true;
65 }
66
67 public boolean nextNode() {
68 return setPosition(position + 1);
69 }
70 }