Class SwitchList

java.lang.Object
com.android.dx.util.MutabilityControl
com.android.dx.cf.code.SwitchList

public final class SwitchList extends MutabilityControl
List of (value, target) mappings representing the choices of a tableswitch or lookupswitch instruction. It also holds the default target for the switch.
  • Constructor Details

    • SwitchList

      public SwitchList(int size)
      Constructs an instance.
      Parameters:
      size - >= 0; the number of elements to be in the table
  • Method Details

    • setImmutable

      public void setImmutable()
      Makes this instance immutable.
      Overrides:
      setImmutable in class MutabilityControl
    • size

      public int size()
      Gets the size of the list.
      Returns:
      >= 0; the list size
    • getValue

      public int getValue(int n)
      Gets the indicated test value.
      Parameters:
      n - >= 0;, < size(); which index
      Returns:
      the test value
    • getTarget

      public int getTarget(int n)
      Gets the indicated target. Asking for the target at size() returns the default target.
      Parameters:
      n - >= 0, <= size(); which index
      Returns:
      >= 0; the target
    • getDefaultTarget

      public int getDefaultTarget()
      Gets the default target. This is just a shorthand for getTarget(size()).
      Returns:
      >= 0; the default target
    • getTargets

      public IntList getTargets()
      Gets the list of all targets. This includes one extra element at the end of the list, which holds the default target.
      Returns:
      non-null; the target list
    • getValues

      public IntList getValues()
      Gets the list of all case values.
      Returns:
      non-null; the case value list
    • setDefaultTarget

      public void setDefaultTarget(int target)
      Sets the default target. It is only valid to call this method when all the non-default elements have been set.
      Parameters:
      target - >= 0; the absolute (not relative) default target address
    • add

      public void add(int value, int target)
      Adds the given item.
      Parameters:
      value - the test value
      target - >= 0; the absolute (not relative) target address
    • removeSuperfluousDefaults

      public void removeSuperfluousDefaults()
      Shrinks this instance if possible, removing test elements that refer to the default target. This is only valid after the instance is fully populated, including the default target (naturally).