Interface IDSwitchData

All Superinterfaces:
IDElement, IInstructionOperand

public interface IDSwitchData extends IDElement
dexdec IR switch data, used to specify the case and target values of a high-level switch instruction.

The keys may be integer or String values.

  • Method Details

    • isEmptySwitch

      boolean isEmptySwitch()
      Determine whether this switch is empty.
      Returns:
    • isRegularSwitch

      boolean isRegularSwitch()
      Determine whether this switch is a normal switch, switching on integer values. An empty switch is considered a regular switch.
      Returns:
    • isStringSwitch

      boolean isStringSwitch()
      Determine whether this switch evaluates and switches on string immediates. Those switches cannot be directly created: a regular switch is converted to a string switch using convertToStringKeys(Map).
      Returns:
    • convertToStringKeys

      boolean convertToStringKeys(Map<Integer,String> convmap)
      Convert a regular switch to a switch-on-strings. This operation is not reversible.
      Parameters:
      convmap - a map of current integer-keys to new string-keys; every integer key must be accounted for, else this method will fail (and the object be left untouched)
      Returns:
      success indicator
    • addCase

      IDTarget addCase(Object key, IDTarget target, boolean overwriteIfKeyExists)
      Add a case to this switch.
      Parameters:
      key - switch key
      target - target
      overwriteIfKeyExists - if false and a case for the provided key exists, this method throws IllegalStateException
      Returns:
      the previous value, if one existed and overwriteIfKeyExists was true
    • getCaseCount

      int getCaseCount()
      Get the number of cases.
      Returns:
    • getCases

      Set<Object> getCases()
      Get the collection of case keys.
      Returns:
    • getCasesAsInt

      Set<Integer> getCasesAsInt()
      Get the collection of case keys as integers. The switch must be a regular switch.
      Returns:
    • getTargetForCase

      IDTarget getTargetForCase(Object key)
      Get the target for the provided case key.
      Parameters:
      key -
      Returns:
    • getTargetCount

      int getTargetCount()
      Get the number of unique targets.
      Returns:
    • getTargets

      Collection<IDTarget> getTargets(boolean removeDuplicates)
      Get the collection of targets.
      Parameters:
      removeDuplicates - if true, the returned collection does not contain duplicate targets; else, it may contain duplicate targets if two or more case keys point to the same target
      Returns:
      a collection of targets
    • getKeysForTargets

      List<Object> getKeysForTargets(IDTarget target)
      Retrieve all case keys that point to the provided target.
      Parameters:
      target -
      Returns:
    • clear

      void clear()
      Delete all cases entry, resulting in an empty switch.
    • deleteCase

      IDTarget deleteCase(Object key)
      Delete a case entry.
      Parameters:
      key - case key
      Returns:
      the target,if the case existed; else, null
    • deleteCasesToTarget

      int deleteCasesToTarget(IDTarget target)
      Delete all cases pointing to the provided target.
      Parameters:
      target -
      Returns:
    • deleteCasesTo

      int deleteCasesTo(int offset)
      Delete all cases pointing to the provided target.
      Parameters:
      offset -
      Returns:
    • updateCases

      int updateCases(int oldOffset, int newOffset)
      Update case targets by offset. All cases pointing to the old target will be updated to point to the new target. Other cases are left untouched.
      Parameters:
      oldOffset -
      newOffset -
      Returns:
      the number of updates
    • updateCases

      int updateCases(Map<Integer,Integer> oldToNewOffsets, boolean failOnMissedEntry)
      Update all case targets by offset. A bulk version of updateCases(int, int).
      Parameters:
      oldToNewOffsets - map of old-to-new offset
      failOnMissedEntry - if true, this method will throw an IllegalArgumentException if an existing case target is unaccounted for
      Returns:
      the number of updates
    • duplicate

      IDSwitchData duplicate()
      Description copied from interface: IDElement
      Duplicate this element.
      Specified by:
      duplicate in interface IDElement
      Returns:
      a deep copy of this element; the type of the duplicated element should be the same as this element's type