/* * TryStatement.java 1.0 * * Jun 20, 1997 mich * Sep 29, 1997 mich * * @see io.devnulllabs.openjava.ptree.ParseTree * @version 1.0 last updated: Sep 29, 1997 * @author Michiaki Tatsubori */ package io.devnulllabs.openjava.ptree; import io.devnulllabs.openjava.ptree.util.ParseTreeVisitor; /** * The TryStatement class represents * a try statement node of parse tree. * * @see io.devnulllabs.openjava.ptree.ParseTree * @see io.devnulllabs.openjava.ptree.NonLeaf * @see io.devnulllabs.openjava.ptree.Statement * @see io.devnulllabs.openjava.ptree.StatementList * @see io.devnulllabs.openjava.ptree.CatchList */ public class TryStatement extends NonLeaf implements Statement, ParseTree { /** * Allocates a new TryStatement object. * * @param the statement list of the body of this try statement. * @param the catch block list of this try statement. * @param the statement list of the finally block. */ public TryStatement( StatementList stmts, CatchList catchlist, StatementList finallee) { super(); if (stmts == null) stmts = new StatementList(); if (catchlist == null) catchlist = new CatchList(); if (finallee == null) finallee = new StatementList(); set(stmts, catchlist, finallee); } /** * Allocates a new TryStatement object. * * @param the statement list of the body of this try statement. * @param the catch block list of this try statement. */ public TryStatement(StatementList stmts, CatchList catchlist) { this(stmts, catchlist, new StatementList()); } /** * Allocates a new TryStatement object. * * @param the statement list of the body of this try statement. * @param the statement list of the finally block. */ public TryStatement(StatementList stmts, StatementList finallee) { this(stmts, new CatchList(), finallee); } TryStatement() { } /** * Gets the body of this try statement. * * @return the statement list of the body. */ public StatementList getBody() { return (StatementList) elementAt(0); } /** * Sets the body of this try statement. * * @param stmts the statement list of the body to set. */ public void setBody(StatementList stmts) { setElementAt(stmts, 0); } /** * Gets the catch block list. * * @return the catch block list. */ public CatchList getCatchList() { return (CatchList) elementAt(1); } /** * Sets the catch block list. * * @param catchlist the catch block list. */ public void setCatchList(CatchList catchlist) { setElementAt(catchlist, 1); } /** * Gets the finally body. * * @return the statement list of finally body. */ public StatementList getFinallyBody() { return (StatementList) elementAt(2); } /** * Sets the finally body. * * @param finallee the statement list of finally body. */ public void setFinallyBody(StatementList finallee) { setElementAt(finallee, 2); } public void accept(ParseTreeVisitor v) throws ParseTreeException { v.visit(this); } }