Class Block
java.lang.Object
org.matwoess.jsourceprofiler.tool.model.Block
- All Implemented Interfaces:
Serializable,Component
This class is used to store information about a code block.
It is the most important class of the model package and used for correct instrumentation and report generation.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal List<CodeRegion> The code regions of this block.The control flow break of this block.longThe number of times this block was hit during execution.intintThe offset for inserting the block's counter-statement.The list of nested blocks for this block.The list of inner blocks that contain a control break.booleanThe labels associated with this block. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCodeRegion(CodeRegion region) Insert the given region into the list of code regions.booleanintReturns the position where the increment statement should be inserted.Returns the list of all inner blocks, below and excluding this one, recursively.inthashCode()booleanReturns whether this block has no curly braces surrounding it.booleanReturns whether this block is a switch expression case.booleanReturns whether this block is a switch statement case.voidregisterInnerControlBreak(Block controlBreakBlock) Add the given block to the list of inner control breaks.voidsetParentBlock(Block block) Registers the parent block object for this block.voidsetParentClass(JClass clazz) Registers the parent class object for this block.voidsetParentMethod(Method method) Registers the parent method object for this block.toString()
-
Field Details
-
id
public int id -
clazz
-
method
-
parentBlock
-
beg
-
end
-
blockType
-
isSingleStatement
public boolean isSingleStatement -
innerBlocks
The list of nested blocks for this block. Empty by default. -
controlBreak
The control flow break of this block. Null if this block is not ending with one. -
labels
The labels associated with this block. Empty by default. -
codeRegions
The code regions of this block. Should never be empty as long asBlockType.hasCounter()is true. -
incInsertOffset
public int incInsertOffsetThe offset for inserting the block's counter-statement. Important for constructor blocks. -
hits
public transient long hitsThe number of times this block was hit during execution.This information is added from the counts.dat file before report generation.
-
innerControlBreaks
The list of inner blocks that contain a control break.Used to determine minus blocks for new code regions.
-
-
Constructor Details
-
Block
Creates a new Block with the given type.- Parameters:
type- the type of the block (one ofBlockType)
-
-
Method Details
-
setParentMethod
Registers the parent method object for this block.If the block is a method block, it also registers this block as the method's method block.
- Parameters:
method- the parent method object
-
setParentClass
Registers the parent class object for this block.Also adds this block to the class' class blocks if it is not a method.
- Parameters:
clazz- the parent class object
-
setParentBlock
Registers the parent block object for this block.Also adds this block to the parent block's inner blocks.
- Parameters:
block- the parent block object
-
registerInnerControlBreak
Add the given block to the list of inner control breaks.- Parameters:
controlBreakBlock- the block containing the control break
-
addCodeRegion
Insert the given region into the list of code regions.- Parameters:
region- the region to add
-
getInnerBlocksRecursive
Returns the list of all inner blocks, below and excluding this one, recursively.- Returns:
- the list of all inner blocks
-
hasNoBraces
public boolean hasNoBraces()Returns whether this block has no curly braces surrounding it.- Returns:
- whether it is a single statement or the block type has no braces
-
isSwitchStatementCase
public boolean isSwitchStatementCase()Returns whether this block is a switch statement case.True if the block is a switch case and its parent block is a switch statement.
- Returns:
- whether this block is a switch statement case
-
isSwitchExpressionCase
public boolean isSwitchExpressionCase()Returns whether this block is a switch expression case.True if the block is a switch case and its parent block is a switch expression.
- Returns:
- whether this block is a switch expression case
-
getIncInsertPos
public int getIncInsertPos()Returns the position where the increment statement should be inserted.- Returns:
- the block begin position plus the increment insert offset
-
toString
-
equals
-
hashCode
public int hashCode()
-