1 46 package org.codehaus.groovy.ast.stmt; 47 48 import java.util.ArrayList ; 49 import java.util.List ; 50 51 import org.codehaus.groovy.ast.GroovyCodeVisitor; 52 53 59 public class TryCatchStatement extends Statement { 60 61 private Statement tryStatement; 62 private List catchStatements = new ArrayList (); 63 private Statement finallyStatement; 64 65 66 public TryCatchStatement(Statement tryStatement, Statement finallyStatement) { 67 this.tryStatement = tryStatement; 68 this.finallyStatement = finallyStatement; 69 } 70 71 public void visit(GroovyCodeVisitor visitor) { 72 visitor.visitTryCatchFinally(this); 73 } 74 75 public List getCatchStatements() { 76 return catchStatements; 77 } 78 79 public Statement getFinallyStatement() { 80 return finallyStatement; 81 } 82 83 public Statement getTryStatement() { 84 return tryStatement; 85 } 86 87 public void addCatch(CatchStatement catchStatement) { 88 catchStatements.add(catchStatement); 89 } 90 91 94 public CatchStatement getCatchStatement(int idx) { 95 if (idx >= 0 && idx < catchStatements.size()) { 96 return (CatchStatement) catchStatements.get(idx); 97 } 98 return null; 99 } 100 } 101 | Popular Tags |