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