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.voidclear()Delete all cases entry, resulting in an empty switch.booleanconvertToStringKeys(Map<Integer, String> convmap) Convert a regular switch to a switch-on-strings.deleteCase(Object key) Delete a case entry.intdeleteCasesTo(int offset) Delete all cases pointing to the provided target.intdeleteCasesToTarget(IDTarget target) Delete all cases pointing to the provided target.Duplicate this element.intGet 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.intGet the number of unique targets.getTargetForCase(Object key) Get the target for the provided case key.getTargets(boolean removeDuplicates) Get the collection of targets.booleanDetermine whether this switch is empty.booleanDetermine whether this switch is a normal switch, switching on integer values.booleanDetermine whether this switch evaluates and switches onstringimmediates.intupdateCases(int oldOffset, int newOffset) Update case targets by offset.intupdateCases(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, toStringMethods inherited from interface com.pnfsoftware.jeb.core.units.code.IInstructionOperand
format
-
Method Details
-
isEmptySwitch
boolean isEmptySwitch()Determine whether this switch is empty.- Returns:
- true if the switch has no cases
-
isRegularSwitch
boolean isRegularSwitch()Determine whether this switch is a normal switch, switching on integer values. An empty switch is considered a regular switch.- Returns:
- true if case keys are integer values
-
isStringSwitch
boolean isStringSwitch()Determine whether this switch evaluates and switches onstringimmediates. Those switches cannot be directly created: a regular switch is converted to a string switch usingconvertToStringKeys(Map).- Returns:
- true if case keys are string values
-
convertToStringKeys
Convert a regular switch to a switch-on-strings. This operation is not reversible.- Parameters:
convmap- a map of currentinteger-keysto 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
overwriteIfKeyExistswas true
-
getCaseCount
int getCaseCount()Get the number of cases.- Returns:
- the case count
-
getCases
Get the collection of case keys.- Returns:
- the case keys
-
getCasesAsInt
Get the collection of case keys as integers. The switch must be a regular switch.- Returns:
- the case keys as integers
-
getTargetForCase
Get the target for the provided case key.- Parameters:
key- case key- Returns:
- the associated target, or null if no case exists for the key
-
getTargetCount
int getTargetCount()Get the number of unique targets.- Returns:
- the number of unique targets
-
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- target to look up- Returns:
- the case keys pointing to the target
-
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- target whose cases should be deleted- Returns:
- the number of deleted cases
-
deleteCasesTo
int deleteCasesTo(int offset) Delete all cases pointing to the provided target.- Parameters:
offset- target offset- Returns:
- the number of deleted cases
-
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- old target offsetnewOffset- new target offset- 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 anIllegalArgumentExceptionif an existing case target is unaccounted for- Returns:
- the number of updates
-
duplicate
IDSwitchData duplicate()Description copied from interface:IDElementDuplicate this element.
-