diff options
Diffstat (limited to 'src/main/java/io/devnulllabs/openjava/ptree/CatchBlock.java')
-rw-r--r-- | src/main/java/io/devnulllabs/openjava/ptree/CatchBlock.java | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/src/main/java/io/devnulllabs/openjava/ptree/CatchBlock.java b/src/main/java/io/devnulllabs/openjava/ptree/CatchBlock.java new file mode 100644 index 0000000..49a1cb7 --- /dev/null +++ b/src/main/java/io/devnulllabs/openjava/ptree/CatchBlock.java @@ -0,0 +1,84 @@ +/* + * CatchBlock.java 1.0 + * + * + * Jun 20, 1997 by mich + * Sep 29, 1997 by bv + * Oct 10, 1997 by mich + * + * @see io.devnulllabs.openjava.ptree.ParseTree + * @version 1.0 last updated: Oct 10, 1997 + * @author Michiaki Tatsubori + */ +package io.devnulllabs.openjava.ptree; + +import io.devnulllabs.openjava.ptree.util.ParseTreeVisitor; + +/** + * The CatchBlock class presents catch node of parse tree + * + * @see io.devnulllabs.openjava.ptree.NonLeaf + * @see io.devnulllabs.openjava.ptree.Parameter + * @see io.devnulllabs.openjava.ptree.StatementList + */ +public class CatchBlock extends NonLeaf { + /** + * Allocates a new CatchBlock object. + * + * @param typespec the exception type specifier. + * @param name the exception variable name. + * @param stmts the statement list of the body. + */ + public CatchBlock(Parameter param, StatementList stmts) { + super(); + if (stmts == null) { + stmts = new StatementList(); + } + set(param, stmts); + } + + CatchBlock() { + super(); + } + + /** + * Gets the exception parameter of this catch block. + * + * @return the exception parameter. + */ + public Parameter getParameter() { + return (Parameter) elementAt(0); + } + + /** + * Sets the exception parameter of this catch block. + * + * @param tspec the exception parameter. + */ + public void setParameter(Parameter param) { + setElementAt(param, 0); + } + + /** + * Gets the body of this catch block. + * + * @return the statement list of the body. + */ + public StatementList getBody() { + return (StatementList) elementAt(1); + } + + /** + * Sets the body of this catch block. + * + * @param stmts the statement list of the body. + */ + public void setBody(StatementList stmts) { + setElementAt(stmts, 1); + } + + public void accept(ParseTreeVisitor v) throws ParseTreeException { + v.visit(this); + } + +} |