1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.commons.jxpath;
17
18 import java.util.List;
19
20 /***
21 * If an extenstion function has an argument of type ExpressionContext,
22 * it can gain access to the current node of an XPath expression context.
23 * <p>
24 * Example:
25 * <blockquote><pre>
26 * public class MyExtenstionFunctions {
27 * public static String objectType(ExpressionContext context){
28 * Object value = context.getContextNodePointer().getValue();
29 * if (value == null){
30 * return "null";
31 * }
32 * return value.getClass().getName();
33 * }
34 * }
35 * </pre></blockquote>
36 *
37 * You can then register this extension function using a {@link ClassFunctions
38 * ClassFunctions} object and call it like this:
39 * <blockquote><pre>
40 * "/descendent-or-self::node()[ns:objectType() = 'java.util.Date']"
41 * </pre></blockquote>
42 * This expression will find all nodes of the graph that are dates.
43 */
44 public interface ExpressionContext {
45
46 /***
47 * Get the JXPathContext in which this function is being evaluated.
48 *
49 * @return A list representing the current context nodes.
50 */
51 JXPathContext getJXPathContext();
52
53 /***
54 * Get the current context node.
55 *
56 * @return The current context node pointer.
57 */
58 Pointer getContextNodePointer();
59
60 /***
61 * Get the current context node list. Each element of the list is
62 * a Pointer.
63 *
64 * @return A list representing the current context nodes.
65 */
66 List getContextNodeList();
67
68 /***
69 * Returns the current context position.
70 */
71 int getPosition();
72 }