1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46 package org.jaxen.expr.iter;
47
48 import java.util.Iterator;
49
50 import org.jaxen.ContextSupport;
51 import org.jaxen.NamedAccessNavigator;
52 import org.jaxen.UnsupportedAxisException;
53
54 /***
55 * Provide access to the child xpath axis.
56 *
57 * @author Bob McWhirter
58 * @author James Strachan
59 * @author Stephen Colebourne
60 */
61 public class IterableChildAxis extends IterableAxis {
62
63 /***
64 * Constructor.
65 *
66 * @param value the axis value
67 */
68 public IterableChildAxis(int value) {
69 super(value);
70 }
71
72 /***
73 * Gets the iterator for the child axis.
74 *
75 * @param contextNode the current context node to work from
76 * @param support the additional context information
77 * @return an iterator over the children of the context node
78 * @throws UnsupportedAxisException if the child axis is not supported
79 */
80 public Iterator iterator(Object contextNode, ContextSupport support)
81 throws UnsupportedAxisException {
82 return support.getNavigator().getChildAxisIterator(contextNode);
83 }
84
85 /***
86 * Gets an iterator for the child XPath axis that supports named access.
87 *
88 * @param contextNode the current context node to work from
89 * @param support the additional context information
90 * @param localName the local name of the children to return
91 * @param namespacePrefix the prefix of the namespace of the children to return
92 * @param namespaceURI the URI of the namespace of the children to return
93 * @return an iterator over the children of the context node
94 * @throws UnsupportedAxisException if the child axis is not supported by the model
95 */
96 public Iterator namedAccessIterator(
97 Object contextNode,
98 ContextSupport support,
99 String localName,
100 String namespacePrefix,
101 String namespaceURI)
102 throws UnsupportedAxisException {
103
104 NamedAccessNavigator nav = (NamedAccessNavigator) support.getNavigator();
105 return nav.getChildAxisIterator(contextNode, localName, namespacePrefix, namespaceURI);
106 }
107
108 /***
109 * Does this axis support named access?
110 *
111 * @param support the additional context information
112 * @return true if named access supported. If not iterator() will be used
113 */
114 public boolean supportsNamedAccess(ContextSupport support) {
115 return (support.getNavigator() instanceof NamedAccessNavigator);
116 }
117
118 }