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
47
48
49 package org.jaxen;
50
51 /*** Resolves variable bindings within an XPath expression.
52 *
53 * <p>
54 * Variables within an XPath expression are denoted using
55 * notation such as <code>$varName</code> or
56 * <code>$nsPrefix:varName</code>, and may
57 * refer to a <code>Boolean</code>, <code>Double</code>, <code>String</code>,
58 * node-set (<code>List</code>) or individual XML node.
59 * </p>
60 *
61 * <p>
62 * When a variable is bound to a node-set, the
63 * actual Java object returned should be a <code>java.util.List</code>
64 * containing XML nodes from the object-model (e.g. dom4j, JDOM, DOM, etc.)
65 * being used with the XPath.
66 * </p>
67 *
68 * <p>
69 * A variable may validly be assigned the <code>null</code> value,
70 * but an unbound variable (one that this context does not know about)
71 * should cause an {@link UnresolvableException} to be thrown.
72 * </p>
73 *
74 * <p>
75 * Implementations of this interface should implement <code>Serializable</code>.
76 * </p>
77 *
78 * @see SimpleVariableContext
79 * @see NamespaceContext
80 *
81 * @author <a href="mailto:bob@werken.com">bob mcwhirter</a>
82 * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
83 */
84 public interface VariableContext
85 {
86 /*** An implementation should return the value of an XPath variable
87 * based on the namespace URI and local name of the variable-reference
88 * expression.
89 *
90 * <p>
91 * It must not use the prefix parameter to select a variable,
92 * because a prefix could be bound to any namespace; the prefix parameter
93 * could be used in debugging output or other generated information.
94 * The prefix may otherwise be ignored.
95 * </p>
96 *
97 * @param namespaceURI the namespace URI to which the prefix parameter
98 * is bound in the XPath expression. If the variable
99 * reference expression had no prefix, the namespace
100 * URI is <code>null</code>.
101 * @param prefix the prefix that was used in the variable reference
102 * expression; this value is ignored and has no effect
103 * @param localName the local name of the variable-reference
104 * expression. If there is no prefix, then this is
105 * the whole name of the variable.
106 *
107 * @return the variable's value (which can be <code>null</code>)
108 * @throws UnresolvableException when the variable cannot be resolved
109 */
110 public Object getVariableValue( String namespaceURI,
111 String prefix,
112 String localName )
113 throws UnresolvableException;
114 }