public interface

IDSwitchData

implements IDElement
com.pnfsoftware.jeb.core.units.code.android.ir.IDSwitchData

Class Overview

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.

Summary

[Expand]
Inherited Constants
From interface com.pnfsoftware.jeb.core.units.code.android.ir.IDElement
Public Methods
abstract IDTarget addCase(Object key, IDTarget target, boolean overwriteIfKeyExists)
Add a case to this switch.
abstract void clear()
Delete all cases entry, resulting in an empty switch.
abstract boolean convertToStringKeys(Map<Integer, String> convmap)
Convert a regular switch to a switch-on-strings.
abstract IDTarget deleteCase(Object key)
Delete a case entry.
abstract int deleteCasesTo(int offset)
Delete all cases pointing to the provided target.
abstract int deleteCasesToTarget(IDTarget target)
Delete all cases pointing to the provided target.
abstract IDSwitchData duplicate()
Duplicate this element.
abstract int getCaseCount()
Get the number of cases.
abstract Set<Object> getCases()
Get the collection of case keys.
abstract Set<Integer> getCasesAsInt()
Get the collection of case keys as integers.
abstract List<Object> getKeysForTargets(IDTarget target)
Retrieve all case keys that point to the provided target.
abstract int getTargetCount()
Get the number of unique targets.
abstract IDTarget getTargetForCase(Object key)
Get the target for the provided case key.
abstract Collection<IDTarget> getTargets(boolean removeDuplicates)
Get the collection of targets.
abstract boolean isEmptySwitch()
Determine whether this switch is empty.
abstract boolean isRegularSwitch()
Determine whether this switch is a normal switch, switching on integer values.
abstract boolean isStringSwitch()
Determine whether this switch evaluates and switches on string immediates.
abstract int updateCases(int oldOffset, int newOffset)
Update case targets by offset.
abstract int updateCases(Map<Integer, Integer> oldToNewOffsets, boolean failOnMissedEntry)
Update all case targets by offset.
[Expand]
Inherited Methods
From interface com.pnfsoftware.jeb.core.units.code.IInstructionOperand
From interface com.pnfsoftware.jeb.core.units.code.android.ir.IDElement

Public Methods

public abstract 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

public abstract void clear ()

Delete all cases entry, resulting in an empty switch.

public abstract 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

public abstract IDTarget deleteCase (Object key)

Delete a case entry.

Parameters
key case key
Returns
  • the target,if the case existed; else, null

public abstract int deleteCasesTo (int offset)

Delete all cases pointing to the provided target.

public abstract int deleteCasesToTarget (IDTarget target)

Delete all cases pointing to the provided target.

public abstract IDSwitchData duplicate ()

Duplicate this element.

Returns
  • a deep copy of this element; the type of the duplicated element should be the same as this element's type

public abstract int getCaseCount ()

Get the number of cases.

public abstract Set<Object> getCases ()

Get the collection of case keys.

public abstract Set<Integer> getCasesAsInt ()

Get the collection of case keys as integers. The switch must be a regular switch.

public abstract List<Object> getKeysForTargets (IDTarget target)

Retrieve all case keys that point to the provided target.

public abstract int getTargetCount ()

Get the number of unique targets.

public abstract IDTarget getTargetForCase (Object key)

Get the target for the provided case key.

public abstract 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

public abstract boolean isEmptySwitch ()

Determine whether this switch is empty.

public abstract boolean isRegularSwitch ()

Determine whether this switch is a normal switch, switching on integer values. An empty switch is considered a regular switch.

public abstract 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).

public abstract 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.

Returns
  • the number of updates

public abstract 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