Package com.android.dx.cf.code
Class SwitchList
java.lang.Object
com.android.dx.util.MutabilityControl
com.android.dx.cf.code.SwitchList
List of (value, target) mappings representing the choices of a
tableswitch
or lookupswitch
instruction. It
also holds the default target for the switch.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(int value, int target) Adds the given item.int
Gets the default target.int
getTarget
(int n) Gets the indicated target.Gets the list of all targets.int
getValue
(int n) Gets the indicated test value.Gets the list of all case values.void
Shrinks this instance if possible, removing test elements that refer to the default target.void
setDefaultTarget
(int target) Sets the default target.void
Makes this instance immutable.int
size()
Gets the size of the list.Methods inherited from class com.android.dx.util.MutabilityControl
isImmutable, isMutable, throwIfImmutable, throwIfMutable
-
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 classMutabilityControl
-
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 atsize()
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 forgetTarget(size())
.- Returns:
>= 0;
the default target
-
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
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 valuetarget
->= 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).
-