public interface

IJavaSwitch

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

Class Overview

Java AST interface to represent switch statements.

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 List<? extends IJavaBlock> getCaseBodies()
Get the case bodies.
abstract IJavaBlock getCaseBody(int key)
Get a case body by key.
abstract Set<Integer> getCaseKeys()
Get the list of case keys.
abstract IJavaBlock getDefaultBody()
Get the default case block.
abstract IJavaExpression getSwitchedExpression()
Get the expression being switched on.
abstract boolean hasDefaultBody()
Determine if the switch block has a default case.
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 List<? extends IJavaBlock> getCaseBodies ()

Get the case bodies.

Returns
  • the list of case bodies

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 Set<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 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 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