# Interface: com.pnfsoftware.jeb.core.units.code.java.IJavaBlock

Java AST interface to represent a sequence of [statements](IJavaStatement). 

 Example: 

```

 {
     stm0;
     stm1;
     stm2;
 }
 
```
 

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

## Method: add
- parameter: `stm`, type: `com.pnfsoftware.jeb.core.units.code.java.IJavaStatement`

Description: Append a statement to this block.
parameter: stm: mandatory statement to be appended

## Method: addAll
- parameter: `b`, type: `com.pnfsoftware.jeb.core.units.code.java.IJavaBlock`

Description: Append all statements of another block to this block.
parameter: b: mandatory source block

## Method: addMultiple
- parameter: `src`, type: `com.pnfsoftware.jeb.core.units.code.java.IJavaBlock`
- parameter: `start`, type: `int`
- parameter: `end`, type: `int`
- parameter: `removeSourceStatements`, type: `boolean`

Description: Append a range of statements from another block.
parameter: src: source block
parameter: start: source start index, inclusive
parameter: end: source end index, exclusive
parameter: removeSourceStatements: true to remove transferred statements from the source block

## Method: clear

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

## Method: duplicate
- return type: `com.pnfsoftware.jeb.core.units.code.java.IJavaBlock`


## Method: generateBody
- parameter: `out`, type: `com.pnfsoftware.jeb.core.units.code.java.JavaOutputSink`

Description: Generate this block body.
parameter: out: output sink

## Method: generateBody
- parameter: `out`, type: `com.pnfsoftware.jeb.core.units.code.java.JavaOutputSink`
- parameter: `expectLambdaExpression`, type: `boolean`

Description: Raw body generation, the caller is responsible for calling generateEnter/generateExit
parameter: out: output sink
parameter: expectLambdaExpression: true if a lambda expression is expected

## Method: generateFooter
- parameter: `out`, type: `com.pnfsoftware.jeb.core.units.code.java.JavaOutputSink`

Description: Generate this block footer.
parameter: out: output sink

## Method: generateHeader
- parameter: `out`, type: `com.pnfsoftware.jeb.core.units.code.java.JavaOutputSink`

Description: Generate this block header.
parameter: out: output sink

## Method: get
- parameter: `index`, type: `int`
- return type: `com.pnfsoftware.jeb.core.units.code.java.IJavaStatement`

Description: Get the statement at a given index.
parameter: index: 0\-based statement index
return: the statement

## Method: getLast
- return type: `com.pnfsoftware.jeb.core.units.code.java.IJavaStatement`

Description: Get the last statement from the block.
return: the non\-null statement

## Method: insert
- parameter: `index`, type: `int`
- parameter: `stm`, type: `com.pnfsoftware.jeb.core.units.code.java.IJavaStatement`

Description: Insert a statement at the given index.
parameter: index: 0\-based statement index
parameter: stm: mandatory statement to be inserted

## Method: insertAll
- parameter: `index`, type: `int`
- parameter: `b`, type: `com.pnfsoftware.jeb.core.units.code.java.IJavaBlock`

Description: Insert all statements of another block in this block.
parameter: index: 0\-based index
parameter: b: mandatory block

## Method: insertMultiple
- parameter: `index`, type: `int`
- parameter: `src`, type: `com.pnfsoftware.jeb.core.units.code.java.IJavaBlock`
- parameter: `start`, type: `int`
- parameter: `end`, type: `int`
- parameter: `removeSourceStatements`, type: `boolean`

Description: Insert a range of statements from another block.
parameter: index: insertion index
parameter: src: source block
parameter: start: source start index, inclusive
parameter: end: source end index, exclusive
parameter: removeSourceStatements: true to remove transferred statements from the source block

## Method: isEmpty
- return type: `boolean`

Description: Determine whether this block contains no statements.
return: true if this block is empty

## Method: remove
- parameter: `index`, type: `int`
- return type: `com.pnfsoftware.jeb.core.units.code.java.IJavaStatement`

Description: Pull a statement from the block.
parameter: index: 0\-based statement index
return: the removed statement

## Method: remove
- parameter: `stm`, type: `com.pnfsoftware.jeb.core.units.code.java.IJavaStatement`
- return type: `boolean`

Description: Remove a statement from the block. Does not throw if the statement is not found.
parameter: stm: mandatory statement
return: success indicator

## Method: removeLast
- return type: `com.pnfsoftware.jeb.core.units.code.java.IJavaStatement`

Description: Pull the last statement from the block.
return: the removed statement

## Method: removeMultiple
- parameter: `index`, type: `int`
- parameter: `cnt`, type: `int`

Description: Remove multiple statements from the block.
parameter: index: 0\-based index of the first statement to remove
parameter: cnt: number of statements to remove

## Method: removeRange
- parameter: `from`, type: `int`
- parameter: `to`, type: `int`

Description: Remove a range of statements from the block.
parameter: from: 0\-based index of the first statement to remove
parameter: to: 0\-based exclusive end index

## Method: set
- parameter: `index`, type: `int`
- parameter: `stm`, type: `com.pnfsoftware.jeb.core.units.code.java.IJavaStatement`

Description: Replace a statement by another statement.
parameter: index: 0\-based statement index
parameter: stm: mandatory statement

## Method: size
- return type: `int`

Description: Get the number of statements in this block. 

 Note: [Compound statements](IJavaCompound) count for a single statement.
return: the number of statements

