Interface IJavaTry
- All Superinterfaces:
IJavaCompound,IJavaElement,IJavaExpression,IJavaStatement
Java AST interface to represent try-catch elements.
- See Also:
-
Field Summary
Fields inherited from interface com.pnfsoftware.jeb.core.units.code.java.IJavaElement
FLAG_BUILT, FLAG_FIELD_REFERENCES_OUTERCLASS, FLAG_LAMBDA_CLASS, FLAG_LAMBDA_IMPL, FLAG_OPTIONAL_RENDERING, FLAG_SECOND_PARAMETER_IS_OUTER_REF, FLAG_STICKY -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCatchBlock(int index, IJavaType type, List<IJavaType> addTypes, IJavaIdentifier ident, IJavaDefinition def, IJavaBlock block) voidaddCatchBlock(IJavaType type, List<IJavaType> addTypes, IJavaIdentifier ident, IJavaDefinition def, IJavaBlock block) voidaddResourceAcq(int i, IJavaExpression exp) voidDuplicate this element.getCatchBlock(int index) getCatchBody(int index) Get a catch body.intgetCatchByType(String typestring) intGet the number of catch blocks.getCatchIdentifier(int index) Get the named identifier associated with the caught exception of a catch block.getCatchType(int index) Get the type of exception caught by a catch block.Get the finally block, if there is one.Get the try block.booleanbooleanremoveCatchBlock(int index) voidremoveResourceAcq(int i) voidvoidSet the try block protected by catch clauses.Methods inherited from interface com.pnfsoftware.jeb.core.units.code.java.IJavaCompound
generateFlatList, getBlocks, getSubElements, insertAt, resetMethods inherited from interface com.pnfsoftware.jeb.core.units.code.java.IJavaElement
addFlags, addTag, canCauseException, collectAllPhysicalOffsets, generate, getData, getElementType, getFlags, getOrigin, getPhysicalMethodIndex, getPhysicalOffset, getReconAnon, getReconEnum, getReconEnummap, getReconLambda, getSubElements, getTags, hasFlags, hasPhysicalMethodIndex, hasPhysicalOffset, isReconArtifact, removeFlags, removeTag, replaceSubElement, setData, setFlags, setLambdaRecon, setOrigin, setPhysicalMethodIndex, setPhysicalOffset, setReconAnon, setReconEnum, setReconEnummap, toShortString, visitDepthPost, visitDepthPost, visitDepthPost, visitDepthPost, visitDepthPre, visitDepthPre, visitDepthPreMethods inherited from interface com.pnfsoftware.jeb.core.units.code.java.IJavaStatement
getIntermediateOffset, setIntermediateOffset
-
Method Details
-
getResourceAcqs
List<IJavaExpression> getResourceAcqs()- Returns:
- a read-only list of acquisition expressions
-
addResourceAcq
- Parameters:
exp- an acquisition expression that will be appended to the current list of acquisition expressions
-
addResourceAcq
- Parameters:
i- insertion indexexp- an acquisition expression that will be added to the current list of acquisition expressions
-
removeResourceAcq
void removeResourceAcq(int i) - Parameters:
i- acquisition expression index
-
isTryWithResource
boolean isTryWithResource()- Returns:
- true if this try-statement is a try-with-resource (a try with resource-acquisition expressions)
-
getTryBody
IJavaBlock getTryBody()Get the try block.- Returns:
- the try block, never null
-
setTryBody
Set the try block protected by catch clauses.- Parameters:
b- a non-null block
-
getCatchCount
int getCatchCount()Get the number of catch blocks.- Returns:
- the number of catch blocks.
-
getCatchBlock
- Parameters:
index-- Returns:
-
removeCatchBlock
- Parameters:
index-- Returns:
-
getCatchBody
Get a catch body.- Parameters:
index- 0-based catch block index- Returns:
- the catch body
-
getCatchType
Get the type of exception caught by a catch block.- Parameters:
index- 0-based catch block index- Returns:
- the caught exception type
-
getCatchIdentifier
Get the named identifier associated with the caught exception of a catch block.- Parameters:
index- 0-based catch block index- Returns:
- the caught exception identifier, may be null if there is none
-
getCatchByType
- Parameters:
typestring-- Returns:
-
getFinallyBlock
IJavaBlock getFinallyBlock()Get the finally block, if there is one.- Returns:
- the finally block, null if there is none
-
setFinallyBlock
- Parameters:
blk-
-
hasFinallyBlock
boolean hasFinallyBlock()- Returns:
-
addCatchBlock
void addCatchBlock(int index, IJavaType type, List<IJavaType> addTypes, IJavaIdentifier ident, IJavaDefinition def, IJavaBlock block) - Parameters:
index-type-addTypes-ident-def-block-
-
addCatchBlock
void addCatchBlock(IJavaType type, List<IJavaType> addTypes, IJavaIdentifier ident, IJavaDefinition def, IJavaBlock block) - Parameters:
type-addTypes-ident-def-block-
-
duplicate
IJavaTry duplicate()Description copied from interface:IJavaElementDuplicate this element.- Specified by:
duplicatein interfaceIJavaCompound- Specified by:
duplicatein interfaceIJavaElement- Specified by:
duplicatein interfaceIJavaExpression- Specified by:
duplicatein interfaceIJavaStatement- Returns:
- a (possibly) duplicated object of the same type
-