public interface

IJavaSwitch

implements ICompound
com.pnfsoftware.jeb.core.units.code.java.IJavaSwitch

Class Overview

Java AST interface to represent switch statements. Support for integer keys and String 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(e)
   case c0: b0
   case c1: b1
   default: b2
 

See Also

Summary

Public Methods
abstract void addCase(List<Integer> keys, IJavaBlock b)
Add a case to the switch
abstract void addCase(Map<Integer, String> casekeymap, IJavaBlock b)
abstract void convertToSwitchOnEnum(IJavaExpression updatedSwitchedOnValue, Map<Integer, IJavaField> enummap)
abstract void convertToSwitchOnInteger(IJavaExpression updatedSwitchedOnValue)
abstract void convertToSwitchOnString(IJavaExpression updatedSwitchedOnValue, Map<Integer, String> indexToStringMap)
abstract List<? extends IJavaBlock> getCaseBodies()
Get the case bodies.
abstract IJavaBlock getCaseBody(String stringkey)
abstract IJavaBlock getCaseBody(int key)
Get a case body by key.
abstract SortedSet<Integer> getCaseKeys()
Get the list of case keys.
abstract IJavaBlock getDefaultBody()
Get the default case block.
abstract Map<Integer, IJavaField> getEnumMap()
abstract Map<Integer, String> getStringMap()
abstract int getSwitchType()
abstract IJavaExpression getSwitchedExpression()
Get the expression being switched on.
abstract boolean hasDefaultBody()
Determine if the switch block has a default case.
abstract boolean isSwitchOnEnum()
abstract boolean isSwitchOnInteger()
abstract boolean isSwitchOnString()
abstract boolean replaceSubElement(IJavaElement oldElement, IJavaElement newElement)
Note: case-replacements are currently not supported.
abstract void setDefaultBody(IJavaBlock b)
Set the default case body for the switch.
abstract void setSwitchedExpression(IJavaExpression e)
Set the switch expression.
[Expand]
Inherited Methods
From interface com.pnfsoftware.jeb.core.units.code.java.ICompound
From interface com.pnfsoftware.jeb.core.units.code.java.IJavaElement

Public Methods

public abstract void addCase (List<Integer> keys, IJavaBlock b)

Add a case to the switch

Parameters
keys mandatory list of keys, this list must contain at least one element
b the case body

public abstract void addCase (Map<Integer, String> casekeymap, IJavaBlock b)

public abstract void convertToSwitchOnEnum (IJavaExpression updatedSwitchedOnValue, Map<Integer, IJavaField> enummap)

public abstract void convertToSwitchOnInteger (IJavaExpression updatedSwitchedOnValue)

public abstract void convertToSwitchOnString (IJavaExpression updatedSwitchedOnValue, Map<Integer, String> indexToStringMap)

public abstract List<? extends IJavaBlock> getCaseBodies ()

Get the case bodies.

Returns
  • the list of case bodies

public abstract IJavaBlock getCaseBody (String stringkey)

public abstract IJavaBlock getCaseBody (int key)

Get a case body by key.

Parameters
key case key
Returns
  • the case body, null if there is no case for the given key

public abstract SortedSet<Integer> getCaseKeys ()

Get the list of case keys.

Returns
  • the list of case keys

public abstract IJavaBlock getDefaultBody ()

Get the default case block.

Returns
  • the default case body, null if there is no default case

public abstract Map<Integer, IJavaField> getEnumMap ()

public abstract Map<Integer, String> getStringMap ()

public abstract int getSwitchType ()

Returns
  • 0=switch-on-int, 1=switch-on-enum, 2=switch-on-string

public abstract IJavaExpression getSwitchedExpression ()

Get the expression being switched on.

Returns
  • the switch expression, never null

public abstract boolean hasDefaultBody ()

Determine if the switch block has a default case.

Returns
  • true if there is a default case

public abstract boolean isSwitchOnEnum ()

public abstract boolean isSwitchOnInteger ()

public abstract boolean isSwitchOnString ()

public abstract boolean replaceSubElement (IJavaElement oldElement, IJavaElement newElement)

Note: case-replacements are currently not supported.

Parameters
oldElement the element to be replaced
newElement the new element

public abstract void setDefaultBody (IJavaBlock b)

Set the default case body for the switch.

Parameters
b optional default case body, null to remove the default case

public abstract void setSwitchedExpression (IJavaExpression e)

Set the switch expression.

Parameters
e mandatory expression