Package org.codehaus.groovy.ast.stmt
Class CatchStatement
java.lang.Object
org.codehaus.groovy.ast.ASTNode
org.codehaus.groovy.ast.stmt.Statement
org.codehaus.groovy.ast.stmt.CatchStatement
- All Implemented Interfaces:
NodeMetaDataHandler
Represents a catch (Exception var) { } statement that handles exceptions in a try-catch block.
Each catch statement specifies an exception type to handle and a code block to execute when
an exception of that type is caught. The exception is bound to a variable that can be
referenced within the catch block.
-
Constructor Summary
ConstructorsConstructorDescriptionCatchStatement(Parameter variable, Statement code) Constructs a catch statement with the given exception parameter and code block. -
Method Summary
Modifier and TypeMethodDescriptiongetCode()Returns the statement executed when the exception is caught.Returns the exception type of this catch statement.Returns the parameter that declares the caught exception variable.voidSets the statement executed when the exception is caught.voidvisit(GroovyCodeVisitor visitor) Accepts a code visitor for AST traversal and transformation.Methods inherited from class org.codehaus.groovy.ast.stmt.Statement
addStatementAnnotation, addStatementLabel, copyStatementLabels, getStatementAnnotations, getStatementLabel, getStatementLabels, isEmpty, setStatementLabelMethods inherited from class org.codehaus.groovy.ast.ASTNode
copyNodeMetaData, getColumnNumber, getLastColumnNumber, getLastLineNumber, getLineNumber, getMetaDataMap, getText, setColumnNumber, setLastColumnNumber, setLastLineNumber, setLineNumber, setMetaDataMap, setSourcePositionMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.codehaus.groovy.ast.NodeMetaDataHandler
copyNodeMetaData, getNodeMetaData, getNodeMetaData, getNodeMetaData, newMetaDataMap, putNodeMetaData, removeNodeMetaData, setNodeMetaData
-
Constructor Details
-
Method Details
-
visit
Description copied from class:ASTNodeAccepts a code visitor for AST traversal and transformation. Subclasses must implement this method to support visitor pattern-based processing. The visitor pattern enables decoupling of AST structure from processing logic.- Overrides:
visitin classASTNode- Parameters:
visitor- theGroovyCodeVisitorto process this node
-
getCode
Returns the statement executed when the exception is caught.- Returns:
- the catch block
Statement
-
getExceptionType
Returns the exception type of this catch statement.- Returns:
- the
ClassNoderepresenting the exception type
-
getVariable
Returns the parameter that declares the caught exception variable.- Returns:
- the exception
Parameter
-
setCode
Sets the statement executed when the exception is caught.- Parameters:
code- the catch blockStatement
-