public interface

IJavaBlock

implements IJavaCompound Iterable<T>
com.pnfsoftware.jeb.core.units.code.java.IJavaBlock

Class Overview

Java AST interface to represent a sequence of statements.

Example:

 {
     stm0;
     stm1;
     stm2;
 }
 

Statements cannot be null. An exception will be raised if an attempt to insert a null statement is made.

Summary

[Expand]
Inherited Constants
From interface com.pnfsoftware.jeb.core.units.code.java.IJavaElement
Public Methods
abstract void add(IJavaStatement stm)
Append a statement to this block.
abstract void addAll(IJavaBlock b)
abstract void addMultiple(IJavaBlock src, int start, int end, boolean removeSourceStatements)
abstract void clear()
Remove all statements of the block, making the block effectively empty: {}
abstract IJavaBlock duplicate()
Duplicate this element.
abstract void generateBody(JavaOutputSink out)
abstract void generateBody(JavaOutputSink out, boolean expectLambdaExpression)
Raw body generation, the caller is responsible for calling generateEnter/generateExit
abstract void generateFooter(JavaOutputSink out)
abstract void generateHeader(JavaOutputSink out)
abstract IJavaStatement get(int index)
Get the statement at a given index.
abstract IJavaStatement getLast()
abstract void insert(int index, IJavaStatement stm)
Insert a statement at the given index.
abstract void insertAll(int index, IJavaBlock b)
Insert all statements of another block in this block.
abstract void insertMultiple(int index, IJavaBlock src, int start, int end, boolean removeSourceStatements)
abstract boolean isEmpty()
abstract IJavaStatement remove(int index)
Pull a statement from the block.
abstract boolean remove(IJavaStatement stm)
Remove a statement from the block.
abstract IJavaStatement removeLast()
abstract void removeMultiple(int index, int cnt)
abstract void removeRange(int from, int to)
abstract void set(int index, IJavaStatement stm)
Replace a statement by another statement.
abstract int size()
Get the number of statements in this block.
[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
From interface java.lang.Iterable

Public Methods

public abstract void add (IJavaStatement stm)

Append a statement to this block.

Parameters
stm mandatory statement to be appended

public abstract void addAll (IJavaBlock b)

public abstract void addMultiple (IJavaBlock src, int start, int end, boolean removeSourceStatements)

public abstract void clear ()

Remove all statements of the block, making the block effectively empty: {}

public abstract IJavaBlock duplicate ()

Duplicate this element.

Returns
  • a (possibly) duplicated object of the same type

public abstract void generateBody (JavaOutputSink out)

public abstract void generateBody (JavaOutputSink out, boolean expectLambdaExpression)

Raw body generation, the caller is responsible for calling generateEnter/generateExit

public abstract void generateFooter (JavaOutputSink out)

public abstract void generateHeader (JavaOutputSink out)

public abstract IJavaStatement get (int index)

Get the statement at a given index.

Parameters
index 0-based statement index
Returns
  • the statement

public abstract IJavaStatement getLast ()

public abstract void insert (int index, IJavaStatement stm)

Insert a statement at the given index.

Parameters
index 0-based statement index
stm mandatory statement to be inserted

public abstract void insertAll (int index, IJavaBlock b)

Insert all statements of another block in this block.

Parameters
index 0-based index
b mandatory block

public abstract void insertMultiple (int index, IJavaBlock src, int start, int end, boolean removeSourceStatements)

public abstract boolean isEmpty ()

public abstract IJavaStatement remove (int index)

Pull a statement from the block.

Parameters
index 0-based statement index
Returns
  • the removed statement

public abstract boolean remove (IJavaStatement stm)

Remove a statement from the block. Does not throw if the statement is not found.

Parameters
stm mandatory statement
Returns
  • success indicator

public abstract IJavaStatement removeLast ()

public abstract void removeMultiple (int index, int cnt)

public abstract void removeRange (int from, int to)

public abstract void set (int index, IJavaStatement stm)

Replace a statement by another statement.

Parameters
index 0-based statement index
stm mandatory statement

public abstract int size ()

Get the number of statements in this block.

Note: Compound statements count for a single statement.

Returns
  • the number of statements