1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.commons.jxpath.ri;
19
20 import java.util.Iterator;
21
22 import org.apache.commons.jxpath.CompiledExpression;
23 import org.apache.commons.jxpath.JXPathContext;
24 import org.apache.commons.jxpath.Pointer;
25 import org.apache.commons.jxpath.ri.compiler.Expression;
26
27
28
29
30 public class JXPathCompiledExpression implements CompiledExpression {
31
32 private final String xpath;
33 private final Expression expression;
34
35
36
37
38
39
40
41 public JXPathCompiledExpression(final String xpath, final Expression expression) {
42 this.xpath = xpath;
43 this.expression = expression;
44 }
45
46 @Override
47 public Pointer createPath(final JXPathContext context) {
48 return ((JXPathContextReferenceImpl) context).createPath(xpath, expression);
49 }
50
51 @Override
52 public Pointer createPathAndSetValue(final JXPathContext context, final Object value) {
53 return ((JXPathContextReferenceImpl) context).createPathAndSetValue(xpath, expression, value);
54 }
55
56
57
58
59
60
61 protected Expression getExpression() {
62 return expression;
63 }
64
65 @Override
66 public Pointer getPointer(final JXPathContext context, final String xpath) {
67 return ((JXPathContextReferenceImpl) context).getPointer(xpath, expression);
68 }
69
70 @Override
71 public Object getValue(final JXPathContext context) {
72 return ((JXPathContextReferenceImpl) context).getValue(xpath, expression);
73 }
74
75 @Override
76 public Object getValue(final JXPathContext context, final Class requiredType) {
77 return ((JXPathContextReferenceImpl) context).getValue(xpath, expression, requiredType);
78 }
79
80
81
82
83
84
85 protected String getXPath() {
86 return xpath;
87 }
88
89 @Override
90 public Iterator iterate(final JXPathContext context) {
91 return ((JXPathContextReferenceImpl) context).iterate(xpath, expression);
92 }
93
94 @Override
95 public Iterator<Pointer> iteratePointers(final JXPathContext context) {
96 return ((JXPathContextReferenceImpl) context).iteratePointers(xpath, expression);
97 }
98
99 @Override
100 public void removeAll(final JXPathContext context) {
101 ((JXPathContextReferenceImpl) context).removeAll(xpath, expression);
102 }
103
104 @Override
105 public void removePath(final JXPathContext context) {
106 ((JXPathContextReferenceImpl) context).removePath(xpath, expression);
107 }
108
109 @Override
110 public void setValue(final JXPathContext context, final Object value) {
111 ((JXPathContextReferenceImpl) context).setValue(xpath, expression, value);
112 }
113
114 @Override
115 public String toString() {
116 return xpath;
117 }
118 }