@@ -247,44 +247,27 @@ public static int getAxisFromStep(final Compiler compiler, final int stepOpCodeP
247247
248248 final int stepType = compiler .getOp (stepOpCodePos );
249249
250- switch (stepType ) {
251- case OpCodes .FROM_FOLLOWING :
252- return Axis .FOLLOWING ;
253- case OpCodes .FROM_FOLLOWING_SIBLINGS :
254- return Axis .FOLLOWINGSIBLING ;
255- case OpCodes .FROM_PRECEDING :
256- return Axis .PRECEDING ;
257- case OpCodes .FROM_PRECEDING_SIBLINGS :
258- return Axis .PRECEDINGSIBLING ;
259- case OpCodes .FROM_PARENT :
260- return Axis .PARENT ;
261- case OpCodes .FROM_NAMESPACE :
262- return Axis .NAMESPACE ;
263- case OpCodes .FROM_ANCESTORS :
264- return Axis .ANCESTOR ;
265- case OpCodes .FROM_ANCESTORS_OR_SELF :
266- return Axis .ANCESTORORSELF ;
267- case OpCodes .FROM_ATTRIBUTES :
268- return Axis .ATTRIBUTE ;
269- case OpCodes .FROM_ROOT :
270- return Axis .ROOT ;
271- case OpCodes .FROM_CHILDREN :
272- return Axis .CHILD ;
273- case OpCodes .FROM_DESCENDANTS_OR_SELF :
274- return Axis .DESCENDANTORSELF ;
275- case OpCodes .FROM_DESCENDANTS :
276- return Axis .DESCENDANT ;
277- case OpCodes .FROM_SELF :
278- return Axis .SELF ;
279- case OpCodes .OP_FUNCTION :
280- case OpCodes .OP_GROUP :
281- case OpCodes .OP_VARIABLE :
282- return Axis .FILTEREDLIST ;
283- }
250+ return switch (stepType ) {
251+ case OpCodes .FROM_FOLLOWING -> Axis .FOLLOWING ;
252+ case OpCodes .FROM_FOLLOWING_SIBLINGS -> Axis .FOLLOWINGSIBLING ;
253+ case OpCodes .FROM_PRECEDING -> Axis .PRECEDING ;
254+ case OpCodes .FROM_PRECEDING_SIBLINGS -> Axis .PRECEDINGSIBLING ;
255+ case OpCodes .FROM_PARENT -> Axis .PARENT ;
256+ case OpCodes .FROM_NAMESPACE -> Axis .NAMESPACE ;
257+ case OpCodes .FROM_ANCESTORS -> Axis .ANCESTOR ;
258+ case OpCodes .FROM_ANCESTORS_OR_SELF -> Axis .ANCESTORORSELF ;
259+ case OpCodes .FROM_ATTRIBUTES -> Axis .ATTRIBUTE ;
260+ case OpCodes .FROM_ROOT -> Axis .ROOT ;
261+ case OpCodes .FROM_CHILDREN -> Axis .CHILD ;
262+ case OpCodes .FROM_DESCENDANTS_OR_SELF -> Axis .DESCENDANTORSELF ;
263+ case OpCodes .FROM_DESCENDANTS -> Axis .DESCENDANT ;
264+ case OpCodes .FROM_SELF -> Axis .SELF ;
265+ case OpCodes .OP_FUNCTION , OpCodes .OP_GROUP , OpCodes .OP_VARIABLE -> Axis .FILTEREDLIST ;
266+ default -> throw new RuntimeException (
267+ XPATHMessages .createXPATHMessage (
268+ XPATHErrorResources .ER_NULL_ERROR_HANDLER , new Object []{Integer .toString (stepType )}));
269+ };
284270
285- throw new RuntimeException (
286- XPATHMessages .createXPATHMessage (
287- XPATHErrorResources .ER_NULL_ERROR_HANDLER , new Object []{Integer .toString (stepType )}));
288271 }
289272
290273 /**
@@ -294,48 +277,27 @@ public static int getAxisFromStep(final Compiler compiler, final int stepOpCodeP
294277 * @return One of BIT_ANCESTOR, etc.
295278 */
296279 public static int getAnalysisBitFromAxes (final int axis ) {
297- switch (axis ) { // Generate new traverser
298- case Axis .ANCESTOR :
299- return BIT_ANCESTOR ;
300- case Axis .ANCESTORORSELF :
301- return BIT_ANCESTOR_OR_SELF ;
302- case Axis .ATTRIBUTE :
303- return BIT_ATTRIBUTE ;
304- case Axis .CHILD :
305- return BIT_CHILD ;
306- case Axis .DESCENDANT :
307- return BIT_DESCENDANT ;
308- case Axis .DESCENDANTORSELF :
309- return BIT_DESCENDANT_OR_SELF ;
310- case Axis .FOLLOWING :
311- return BIT_FOLLOWING ;
312- case Axis .FOLLOWINGSIBLING :
313- return BIT_FOLLOWING_SIBLING ;
314- case Axis .NAMESPACE :
315- case Axis .NAMESPACEDECLS :
316- return BIT_NAMESPACE ;
317- case Axis .PARENT :
318- return BIT_PARENT ;
319- case Axis .PRECEDING :
320- return BIT_PRECEDING ;
321- case Axis .PRECEDINGSIBLING :
322- return BIT_PRECEDING_SIBLING ;
323- case Axis .SELF :
324- return BIT_SELF ;
325- case Axis .ALLFROMNODE :
326- return BIT_DESCENDANT_OR_SELF ;
280+ return switch (axis ) { // Generate new traverser
281+ case Axis .ANCESTOR -> BIT_ANCESTOR ;
282+ case Axis .ANCESTORORSELF -> BIT_ANCESTOR_OR_SELF ;
283+ case Axis .ATTRIBUTE -> BIT_ATTRIBUTE ;
284+ case Axis .CHILD -> BIT_CHILD ;
285+ case Axis .DESCENDANT -> BIT_DESCENDANT ;
286+ case Axis .DESCENDANTORSELF -> BIT_DESCENDANT_OR_SELF ;
287+ case Axis .FOLLOWING -> BIT_FOLLOWING ;
288+ case Axis .FOLLOWINGSIBLING -> BIT_FOLLOWING_SIBLING ;
289+ case Axis .NAMESPACE , Axis .NAMESPACEDECLS -> BIT_NAMESPACE ;
290+ case Axis .PARENT -> BIT_PARENT ;
291+ case Axis .PRECEDING -> BIT_PRECEDING ;
292+ case Axis .PRECEDINGSIBLING -> BIT_PRECEDING_SIBLING ;
293+ case Axis .SELF -> BIT_SELF ;
294+ case Axis .ALLFROMNODE -> BIT_DESCENDANT_OR_SELF ;
327295 // case Axis.PRECEDINGANDANCESTOR :
328- case Axis .DESCENDANTSFROMROOT :
329- case Axis .ALL :
330- case Axis .DESCENDANTSORSELFFROMROOT :
331- return BIT_ANY_DESCENDANT_FROM_ROOT ;
332- case Axis .ROOT :
333- return BIT_ROOT ;
334- case Axis .FILTEREDLIST :
335- return BIT_FILTER ;
336- default :
337- return BIT_FILTER ;
338- }
296+ case Axis .DESCENDANTSFROMROOT , Axis .ALL , Axis .DESCENDANTSORSELFFROMROOT -> BIT_ANY_DESCENDANT_FROM_ROOT ;
297+ case Axis .ROOT -> BIT_ROOT ;
298+ case Axis .FILTEREDLIST -> BIT_FILTER ;
299+ default -> BIT_FILTER ;
300+ };
339301 }
340302
341303 static boolean functionProximateOrContainsProximate (final Compiler compiler , int opPos ) {
@@ -862,17 +824,10 @@ private static StepPattern createDefaultStepPattern(final Compiler compiler, fin
862824 case OpCodes .OP_VARIABLE :
863825 case OpCodes .OP_FUNCTION :
864826 case OpCodes .OP_GROUP :
865- final Expression expr ;
866-
867- switch (stepType ) {
868- case OpCodes .OP_VARIABLE :
869- case OpCodes .OP_FUNCTION :
870- case OpCodes .OP_GROUP :
871- expr = compiler .compile (opPos );
872- break ;
873- default :
874- expr = compiler .compile (opPos + 2 );
875- }
827+ final Expression expr = switch (stepType ) {
828+ case OpCodes .OP_VARIABLE , OpCodes .OP_FUNCTION , OpCodes .OP_GROUP -> compiler .compile (opPos );
829+ default -> compiler .compile (opPos + 2 );
830+ };
876831
877832 axis = Axis .FILTEREDLIST ;
878833 ai = new FunctionPattern (expr , axis );
0 commit comments