Interface IDSwitchData
- All Superinterfaces:
IDElement
,IInstructionOperand
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.
-
Field Summary
Fields inherited from interface com.pnfsoftware.jeb.core.units.code.android.ir.IDElement
DEFAULT_COMPARE_WITH_FULL_EQUALITY
-
Method Summary
Modifier and TypeMethodDescriptionAdd a case to this switch.void
clear()
Delete all cases entry, resulting in an empty switch.boolean
convertToStringKeys
(Map<Integer, String> convmap) Convert a regular switch to a switch-on-strings.deleteCase
(Object key) Delete a case entry.int
deleteCasesTo
(int offset) Delete all cases pointing to the provided target.int
deleteCasesToTarget
(IDTarget target) Delete all cases pointing to the provided target.Duplicate this element.int
Get the number of cases.getCases()
Get the collection of case keys.Get the collection of case keys as integers.getKeysForTargets
(IDTarget target) Retrieve all case keys that point to the provided target.int
Get the number of unique targets.getTargetForCase
(Object key) Get the target for the provided case key.getTargets
(boolean removeDuplicates) Get the collection of targets.boolean
Determine whether this switch is empty.boolean
Determine whether this switch is a normal switch, switching on integer values.boolean
Determine whether this switch evaluates and switches onstring
immediates.int
updateCases
(int oldOffset, int newOffset) Update case targets by offset.int
updateCases
(Map<Integer, Integer> oldToNewOffsets, boolean failOnMissedEntry) Update all case targets by offset.Methods inherited from interface com.pnfsoftware.jeb.core.units.code.android.ir.IDElement
copy, equalsEx, format, toString, toString
Methods inherited from interface com.pnfsoftware.jeb.core.units.code.IInstructionOperand
format
-
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 onstring
immediates. Those switches cannot be directly created: a regular switch is converted to a string switch usingconvertToStringKeys(Map)
.- Returns:
-
convertToStringKeys
Convert a regular switch to a switch-on-strings. This operation is not reversible.- Parameters:
convmap
- a map of currentinteger-keys
to newstring-keys
; every integer key must be accounted for, else this method will fail (and the object be left untouched)- Returns:
- success indicator
-
addCase
Add a case to this switch.- Parameters:
key
- switch keytarget
- targetoverwriteIfKeyExists
- if false and a case for the provided key exists, this method throwsIllegalStateException
- Returns:
- the previous value, if one existed and
overwriteIfKeyExists
was true
-
getCaseCount
int getCaseCount()Get the number of cases.- Returns:
-
getCases
Get the collection of case keys.- Returns:
-
getCasesAsInt
Get the collection of case keys as integers. The switch must be a regular switch.- Returns:
-
getTargetForCase
Get the target for the provided case key.- Parameters:
key
-- Returns:
-
getTargetCount
int getTargetCount()Get the number of unique targets.- Returns:
-
getTargets
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
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
Delete a case entry.- Parameters:
key
- case key- Returns:
- the target,if the case existed; else, null
-
deleteCasesToTarget
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
Update all case targets by offset. A bulk version ofupdateCases(int, int)
.- Parameters:
oldToNewOffsets
- map of old-to-new offsetfailOnMissedEntry
- if true, this method will throw anIllegalArgumentException
if an existing case target is unaccounted for- Returns:
- the number of updates
-
duplicate
IDSwitchData duplicate()Description copied from interface:IDElement
Duplicate this element.
-