com.pnfsoftware.jeb.core.units.code.java.IJavaIf |
Java AST interface to represent a conditional "if" statement.
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
[Expand]
Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From interface
com.pnfsoftware.jeb.core.units.code.java.IJavaElement
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
abstract void |
addBranch(IJavaPredicate p, IJavaBlock b)
Add an alternative block (if or else-if) to this element.
| ||||||||||
abstract IJavaIf |
duplicate()
Duplicate this element.
| ||||||||||
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 List<IJavaPredicate> |
getBranchPredicates()
Get the predicates.
| ||||||||||
abstract IJavaBlock |
getDefaultBlock()
Get the default branch (else) body, if any.
| ||||||||||
abstract boolean |
hasDefaultBlock()
Determine whether that if-statement has a default block.
| ||||||||||
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.
| ||||||||||
abstract int |
sizeWithoutDefault()
Return the number of blocks (if, else-ifs), NOT counting the else block if there is one.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From interface
com.pnfsoftware.jeb.core.units.code.java.IJavaCompound
| |||||||||||
From interface
com.pnfsoftware.jeb.core.units.code.java.IJavaElement
| |||||||||||
From interface
com.pnfsoftware.jeb.core.units.code.java.IJavaExpression
| |||||||||||
From interface
com.pnfsoftware.jeb.core.units.code.java.IJavaStatement
|
Add an alternative block (if or else-if) to this element.
p | mandatory predicate |
---|---|
b | mandatory statement |
Duplicate this element.
Get a branch (if, else-if) body.
index | 0-based branch index (0 for 'if', 1... for subsequent else-ifs) |
---|
Get a branch (if, else-if) predicate.
index | 0-based branch index (0 for 'if', 1... for subsequent else-ifs) |
---|
Get the predicates. Warning, this is the actual list of predicates, not a copy. Caution should be exercised when modifying it
Get the default branch (else) body, if any.
Determine whether that if-statement has a default block.
Insert a branch (if, else-if) to this statement.
index | 0-based branch index |
---|---|
p | mandatory predicate |
b | mandatory body |
Remove a branch from this statement.
index | 0-based branch index |
---|
Set a branch (if, else-if) body.
index | 0-based branch index |
---|---|
b | mandatory body |
Set a branch (if, else-if) predicate.
index | 0-based branch index |
---|---|
p | mandatory predicate |
Set the default 'else' block.
b | new default block, null for none |
---|
Get the number of branches, including the default (else) branch, if any.
Return the number of blocks (if, else-ifs), NOT counting the else block if there is one.