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 XPath attribute axis.
56 * This axis does not include namespace declarations such as
57 * <code>xmlns</code> and <code>xmlns:<i>prefix</i></code>.
58 * It does include attributes defaulted from the DTD.
59 *
60 * @author Bob McWhirter
61 * @author James Strachan
62 * @author Stephen Colebourne
63 */
64 public class IterableAttributeAxis extends IterableAxis {
65
66 /***
67 * Constructor.
68 *
69 * @param value the axis value
70 */
71 public IterableAttributeAxis(int value) {
72 super(value);
73 }
74
75 /***
76 * Gets an iterator for the attribute axis.
77 *
78 * @param contextNode the current context node to work from
79 * @param support the additional context information
80 */
81 public Iterator iterator(Object contextNode, ContextSupport support) throws UnsupportedAxisException {
82 return support.getNavigator().getAttributeAxisIterator(contextNode);
83 }
84
85 /***
86 * Gets the iterator for the attribute 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 attributes to return
91 * @param namespacePrefix the prefix of the namespace of the attributes to return
92 * @param namespaceURI the uri of the namespace of the attributes to return
93 */
94 public Iterator namedAccessIterator(
95 Object contextNode,
96 ContextSupport support,
97 String localName,
98 String namespacePrefix,
99 String namespaceURI)
100 throws UnsupportedAxisException {
101
102 NamedAccessNavigator nav = (NamedAccessNavigator) support.getNavigator();
103 return nav.getAttributeAxisIterator(contextNode, localName, namespacePrefix, namespaceURI);
104 }
105
106 /***
107 * Does this axis support named access?
108 *
109 * @param support the additional context information
110 * @return true if named access is supported. If not iterator() will be used.
111 */
112 public boolean supportsNamedAccess(ContextSupport support) {
113 return (support.getNavigator() instanceof NamedAccessNavigator);
114 }
115
116 }