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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64 package org.jaxen.saxpath;
65
66 import org.jaxen.JaxenRuntimeException;
67
68
69
70 public class Axis
71 {
72
73
74 /*** Marker for an invalid axis */
75 public final static int INVALID_AXIS = 0;
76
77 /*** The <code>child</code> axis */
78 public final static int CHILD = 1;
79
80 /*** The <code>descendant</code> axis */
81 public final static int DESCENDANT = 2;
82
83 /*** The <code>parent</code> axis */
84 public final static int PARENT = 3;
85
86 /*** The <code>ancestor</code> axis */
87 public final static int ANCESTOR = 4;
88
89 /*** The <code>following-sibling</code> axis */
90 public final static int FOLLOWING_SIBLING = 5;
91
92 /*** The <code>preceding-sibling</code> axis */
93 public final static int PRECEDING_SIBLING = 6;
94
95 /*** The <code>following</code> axis */
96 public final static int FOLLOWING = 7;
97
98 /*** The <code>preceding</code> axis */
99 public final static int PRECEDING = 8;
100
101 /*** The <code>attribute</code> axis */
102 public final static int ATTRIBUTE = 9;
103
104 /*** The <code>namespace</code> axis */
105 public final static int NAMESPACE = 10;
106
107 /*** The <code>self</code> axis */
108 public final static int SELF = 11;
109
110 /*** The <code>descendant-or-self</code> axis */
111 public final static int DESCENDANT_OR_SELF = 12;
112
113 /*** The <code>ancestor-or-self</code> axis */
114 public final static int ANCESTOR_OR_SELF = 13;
115
116 public static String lookup(int axisNum)
117 {
118 switch ( axisNum )
119 {
120 case CHILD:
121 return "child";
122
123 case DESCENDANT:
124 return "descendant";
125
126 case PARENT:
127 return "parent";
128
129 case ANCESTOR:
130 return "ancestor";
131
132 case FOLLOWING_SIBLING:
133 return "following-sibling";
134
135 case PRECEDING_SIBLING:
136 return "preceding-sibling";
137
138 case FOLLOWING:
139 return "following";
140
141 case PRECEDING:
142 return "preceding";
143
144 case ATTRIBUTE:
145 return "attribute";
146
147 case NAMESPACE:
148 return "namespace";
149
150 case SELF:
151 return "self";
152
153 case DESCENDANT_OR_SELF:
154 return "descendant-or-self";
155
156 case ANCESTOR_OR_SELF:
157 return "ancestor-or-self";
158 }
159
160 throw new JaxenRuntimeException("Illegal Axis Number");
161 }
162
163 public static int lookup(String axisName)
164 {
165 if ( "child".equals( axisName ) )
166 {
167 return CHILD;
168 }
169
170 if ( "descendant".equals( axisName ) )
171 {
172 return DESCENDANT;
173 }
174
175 if ( "parent".equals( axisName ) )
176 {
177 return PARENT;
178 }
179
180 if ( "ancestor".equals( axisName ) )
181 {
182 return ANCESTOR;
183 }
184
185 if ( "following-sibling".equals( axisName ) )
186 {
187 return FOLLOWING_SIBLING;
188 }
189
190 if ( "preceding-sibling".equals( axisName ) )
191 {
192 return PRECEDING_SIBLING;
193 }
194
195 if ( "following".equals( axisName ) )
196 {
197 return FOLLOWING;
198 }
199
200 if ( "preceding".equals( axisName ) )
201 {
202 return PRECEDING;
203 }
204
205 if ( "attribute".equals( axisName ) )
206 {
207 return ATTRIBUTE;
208 }
209
210 if ( "namespace".equals( axisName ) )
211 {
212 return NAMESPACE;
213 }
214
215 if ( "self".equals( axisName ) )
216 {
217 return SELF;
218 }
219
220 if ( "descendant-or-self".equals( axisName ) )
221 {
222 return DESCENDANT_OR_SELF;
223 }
224
225 if ( "ancestor-or-self".equals( axisName ) )
226 {
227 return ANCESTOR_OR_SELF;
228 }
229
230 return INVALID_AXIS;
231 }
232 }