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 package org.jaxen.expr.iter;
35
36 import java.util.Iterator;
37
38 import org.jaxen.ContextSupport;
39 import org.jaxen.NamedAccessNavigator;
40 import org.jaxen.UnsupportedAxisException;
41
42 /***
43 * Provide access to the XPath attribute axis.
44 * This axis does not include namespace declarations such as
45 * <code>xmlns</code> and <code>xmlns:<i>prefix</i></code>.
46 * It does include attributes defaulted from the DTD.
47 *
48 * @author Bob McWhirter
49 * @author James Strachan
50 * @author Stephen Colebourne
51 */
52 public class IterableAttributeAxis extends IterableAxis {
53
54 /***
55 *
56 */
57 private static final long serialVersionUID = 1L;
58
59 /***
60 * Constructor.
61 *
62 * @param value the axis value
63 */
64 public IterableAttributeAxis(int value) {
65 super(value);
66 }
67
68 /***
69 * Gets an iterator for the attribute axis.
70 *
71 * @param contextNode the current context node to work from
72 * @param support the additional context information
73 */
74 public Iterator iterator(Object contextNode, ContextSupport support) throws UnsupportedAxisException {
75 return support.getNavigator().getAttributeAxisIterator(contextNode);
76 }
77
78 /***
79 * Gets the iterator for the attribute axis that supports named access.
80 *
81 * @param contextNode the current context node to work from
82 * @param support the additional context information
83 * @param localName the local name of the attributes to return
84 * @param namespacePrefix the prefix of the namespace of the attributes to return
85 * @param namespaceURI the uri of the namespace of the attributes to return
86 */
87 public Iterator namedAccessIterator(
88 Object contextNode,
89 ContextSupport support,
90 String localName,
91 String namespacePrefix,
92 String namespaceURI)
93 throws UnsupportedAxisException {
94
95 NamedAccessNavigator nav = (NamedAccessNavigator) support.getNavigator();
96 return nav.getAttributeAxisIterator(contextNode, localName, namespacePrefix, namespaceURI);
97 }
98
99 /***
100 * Does this axis support named access?
101 *
102 * @param support the additional context information
103 * @return true if named access is supported. If not iterator() will be used.
104 */
105 public boolean supportsNamedAccess(ContextSupport support) {
106 return (support.getNavigator() instanceof NamedAccessNavigator);
107 }
108
109 }