com.android.dx.cf.code
Class SwitchList

java.lang.Object
  extended by com.android.dx.util.MutabilityControl
      extended by com.android.dx.cf.code.SwitchList

public final class SwitchList
extends MutabilityControl

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
SwitchList(int size)
          Constructs an instance.
 
Method Summary
 void add(int value, int target)
          Adds the given item.
 int getDefaultTarget()
          Gets the default target.
 int getTarget(int n)
          Gets the indicated target.
 IntList getTargets()
          Gets the list of all targets.
 int getValue(int n)
          Gets the indicated test value.
 IntList getValues()
          Gets the list of all case values.
 void removeSuperfluousDefaults()
          Shrinks this instance if possible, removing test elements that refer to the default target.
 void setDefaultTarget(int target)
          Sets the default target.
 void setImmutable()
          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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SwitchList

public SwitchList(int size)
Constructs an instance.

Parameters:
size - >= 0; the number of elements to be in the table
Method Detail

setImmutable

public void setImmutable()
Makes this instance immutable.

Overrides:
setImmutable in class MutabilityControl

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 at size() 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 for getTarget(size()).

Returns:
>= 0; the default target

getTargets

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

public IntList 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 value
target - >= 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).



Copyright © 2015. All rights reserved.