org.apache.bcel.generic

## Class SWITCH

- java.lang.Object
- - org.apache.bcel.generic.SWITCH

- All Implemented Interfaces:
    CompoundInstruction

      public final class SWITCH
      extends Object
      implements CompoundInstruction

  SWITCH - Branch depending on int value, generates either LOOKUPSWITCH or TABLESWITCH instruction, depending on whether the match values (int[]) can be sorted with no gaps between the numbers.
  Version:
    $Id: SWITCH.java 1806200 2017-08-25 16:33:06Z ggregory $

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `SWITCH(int[] match, InstructionHandle[] targets, InstructionHandle target)`
    `SWITCH(int[] match, InstructionHandle[] targets, InstructionHandle target, int max_gap)` Template for switch() constructs.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `Instruction` | `getInstruction()`
    `InstructionList` | `getInstructionList()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### SWITCH

          public SWITCH(int[] match,
                        InstructionHandle[] targets,
                        InstructionHandle target,
                        int max_gap)

      Template for switch() constructs. If the match array can be sorted in ascending order with gaps no larger than max_gap between the numbers, a TABLESWITCH instruction is generated, and a LOOKUPSWITCH otherwise. The former may be more efficient, but needs more space. Note, that the key array always will be sorted, though we leave the original arrays unaltered.
      Parameters:
        `match` - array of match values (case 2: ... case 7: ..., etc.)
        `targets` - the instructions to be branched to for each case
        `target` - the default target
        `max_gap` - maximum gap that may between case branches

    - #### SWITCH

          public SWITCH(int[] match,
                        InstructionHandle[] targets,
                        InstructionHandle target)

  - ### Method Detail

    - #### getInstructionList

          public final InstructionList getInstructionList()

      Specified by:
        `getInstructionList` in interface `CompoundInstruction`

    - #### getInstruction

          public final Instruction getInstruction()

Copyright © 2004–2019 The Apache Software Foundation. All rights reserved.