1 18 package org.apache.geronimo.interop.generator; 19 20 import java.util.Vector ; 21 22 public class JTryCatchFinallyStatement extends JStatement { 23 private JTryStatement tryStatement; 24 private Vector catchStatements; 25 private JFinallyStatement finallyStatement; 26 27 public JTryCatchFinallyStatement() { 28 tryStatement = new JTryStatement(); 29 catchStatements = new Vector (); 30 finallyStatement = new JFinallyStatement(); 31 } 32 33 public void addTryStatement(JStatement s) { 34 tryStatement.addStatement(s); 35 } 36 37 public JTryStatement getTryStatement() { 38 return tryStatement; 39 } 40 41 public JCatchStatement getCatch(JVariable v) { 42 JCatchStatement rc = null; 43 int index = catchStatements.indexOf(v); 44 45 if (index >= 0) { 46 rc = (JCatchStatement) catchStatements.get(index); 47 } 48 49 return rc; 50 } 51 52 public JCatchStatement newCatch(JVariable v) { 53 JCatchStatement rc = getCatch(v); 54 55 if (rc == null) { 56 rc = new JCatchStatement(v); 57 catchStatements.add(rc); 58 } 59 60 return rc; 61 } 62 63 public void addCatchStatement(JVariable v, JStatement s) { 64 JCatchStatement cs = getCatch(v); 65 66 if (cs == null) { 67 cs = newCatch(v); 68 } 69 70 cs.addStatement(s); 71 } 72 73 public Vector getCatches() { 74 return catchStatements; 75 } 76 77 public void addFinallyStatement(JStatement s) { 78 finallyStatement.addStatement(s); 79 } 80 81 public JFinallyStatement getFinallyStatement() { 82 return finallyStatement; 83 } 84 } 85 | Popular Tags |