public interface

IJavaIf

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

Class Overview

Java AST interface to represent conditional "if" statements.

An if-statement consists of one or more branches (if, else-if) followed by an optional default branch (else) block.

Example:

 if(p)
   b
 else if(p1)
   b1
 else
   b2
 

Summary

Public Methods
abstract IJavaBlock getBranchBody(int index)
Get a branch (if, else-if) body.
abstract IJavaPredicate getBranchPredicate(int index)
Get a branch (if, else-if) predicate.
abstract IJavaBlock getDefaultBlock()
Get the default branch (else) body, if any.
abstract void insertBranch(int index, IJavaPredicate p, IJavaBlock b)
Insert a branch (if, else-if) to this statement.
abstract void removeBranch(int index)
Remove a branch from this statement.
abstract void setBranchBody(int index, IJavaBlock b)
Set a branch (if, else-if) body.
abstract void setBranchPredicate(int index, IJavaPredicate p)
Set a branch (if, else-if) predicate.
abstract IJavaBlock setDefaultBlock(IJavaBlock b)
Set the default 'else' block.
abstract int size()
Get the number of branches, including the default (else) branch, if any.
[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 IJavaBlock getBranchBody (int index)

Get a branch (if, else-if) body.

Parameters
index 0-based branch index (0 for 'if', 1... for subsequent else-ifs)
Returns
  • the body

public abstract IJavaPredicate getBranchPredicate (int index)

Get a branch (if, else-if) predicate.

Parameters
index 0-based branch index (0 for 'if', 1... for subsequent else-ifs)
Returns
  • the predicate

public abstract IJavaBlock getDefaultBlock ()

Get the default branch (else) body, if any.

Returns
  • the default branch body, null if there is none

public abstract void insertBranch (int index, IJavaPredicate p, IJavaBlock b)

Insert a branch (if, else-if) to this statement.

Parameters
index 0-based branch index
p mandatory predicate
b mandatory body

public abstract void removeBranch (int index)

Remove a branch from this statement.

Parameters
index 0-based branch index

public abstract void setBranchBody (int index, IJavaBlock b)

Set a branch (if, else-if) body.

Parameters
index 0-based branch index
b mandatory body

public abstract void setBranchPredicate (int index, IJavaPredicate p)

Set a branch (if, else-if) predicate.

Parameters
index 0-based branch index
p mandatory predicate

public abstract IJavaBlock setDefaultBlock (IJavaBlock b)

Set the default 'else' block.

Parameters
b new default block, null for none
Returns
  • the previous default block

public abstract int size ()

Get the number of branches, including the default (else) branch, if any.

Returns
  • the number of branches