# Interface: com.pnfsoftware.jeb.core.units.code.java.IJavaSwitch

Java AST interface to represent `switch` statements. They support integer keys \(standard switch\), String keys, and Enum keys. Limitation: These objects do not support case\-block replacement. 

 A switch\-statement consists of an expression, zero or more cases and an optional default case. 

 Example:  

```

 switch(exp)
   case c0: b0
   case c1: b1
   default: b2
 
```

## Method: addCase
- parameter: `keys`, type: `java.util.List<java.lang.Integer>`
- parameter: `b`, type: `com.pnfsoftware.jeb.core.units.code.java.IJavaBlock`

Description: Add a case to the switch
parameter: keys: mandatory list of keys, this list must contain at least one element
parameter: b: the case body

## Method: addCase
- parameter: `casekeymap`, type: `java.util.Map<java.lang.Integer,java.lang.String>`
- parameter: `b`, type: `com.pnfsoftware.jeb.core.units.code.java.IJavaBlock`

Description: 
parameter: casekeymap: 
parameter: b: 

## Method: convertToSwitchOnEnum
- parameter: `updatedSwitchedOnValue`, type: `com.pnfsoftware.jeb.core.units.code.java.IJavaExpression`
- parameter: `enummap`, type: `java.util.Map<java.lang.Integer,java.lang.String>`

Description: 
parameter: updatedSwitchedOnValue: 
parameter: enummap: 

## Method: convertToSwitchOnInteger
- parameter: `updatedSwitchedOnValue`, type: `com.pnfsoftware.jeb.core.units.code.java.IJavaExpression`

Description: 
parameter: updatedSwitchedOnValue: 

## Method: convertToSwitchOnString
- parameter: `updatedSwitchedOnValue`, type: `com.pnfsoftware.jeb.core.units.code.java.IJavaExpression`
- parameter: `indexToStringMap`, type: `java.util.Map<java.lang.Integer,java.lang.String>`

Description: 
parameter: updatedSwitchedOnValue: 
parameter: indexToStringMap: 

## Method: duplicate
- return type: `com.pnfsoftware.jeb.core.units.code.java.IJavaSwitch`


## Method: getCaseBodies
- return type: `java.util.List<com.pnfsoftware.jeb.core.units.code.java.IJavaBlock>`

Description: Get the case bodies.
return: the list of case bodies

## Method: getCaseBody
- parameter: `key`, type: `int`
- return type: `com.pnfsoftware.jeb.core.units.code.java.IJavaBlock`

Description: Get a case body by key.
parameter: key: case key
return: the case body, null if there is no case for the given key

## Method: getCaseBody
- parameter: `stringkey`, type: `java.lang.String`
- return type: `com.pnfsoftware.jeb.core.units.code.java.IJavaBlock`

Description: 
parameter: stringkey: 
return: 

## Method: getCaseKeys
- return type: `java.util.SortedSet<java.lang.Integer>`

Description: Get the list of case keys.
return: the list of case keys

## Method: getDefaultBlock
- return type: `com.pnfsoftware.jeb.core.units.code.java.IJavaBlock`

Description: Get the default case block.
return: the default case body, null if there is no default case

## Method: getEnumMap
- return type: `java.util.Map<java.lang.Integer,java.lang.String>`

Description: 
return: 

## Method: getStringMap
- return type: `java.util.Map<java.lang.Integer,java.lang.String>`

Description: 
return: 

## Method: getSwitchType
- return type: `int`

Description: 
return: 0=switch\-on\-int, 1=switch\-on\-enum, 2=switch\-on\-string

## Method: getSwitchedExpression
- return type: `com.pnfsoftware.jeb.core.units.code.java.IJavaExpression`

Description: Get the expression being switched on.
return: the switch expression, never null

## Method: hasDefaultBlock
- return type: `boolean`

Description: Determine if the switch block has a default case.
return: true if there is a default case

## Method: isSwitchOnEnum
- return type: `boolean`

Description: 
return: 

## Method: isSwitchOnInteger
- return type: `boolean`

Description: 
return: 

## Method: isSwitchOnString
- return type: `boolean`

Description: 
return: 

## Method: replaceSubElement
- parameter: `oldElement`, type: `com.pnfsoftware.jeb.core.units.code.java.IJavaElement`
- parameter: `newElement`, type: `com.pnfsoftware.jeb.core.units.code.java.IJavaElement`
- return type: `boolean`

Description: Note: case\-replacements are currently not supported.

## Method: reset
- parameter: `type`, type: `int`

Description: Reset this switch to a potentially different switch type. This is a specialized version of [#reset()](#reset()).
parameter: type: 0=switch\-on\-int; 1=switch\-on\-enum; 2=switch\-on\-string

## Method: setDefaultBlock
- parameter: `b`, type: `com.pnfsoftware.jeb.core.units.code.java.IJavaBlock`

Description: Set the default case block for the switch.
parameter: b: optional default case body, null to remove the default case

## Method: setSwitchedExpression
- parameter: `e`, type: `com.pnfsoftware.jeb.core.units.code.java.IJavaExpression`

Description: Set the switch expression.
parameter: e: mandatory expression

