1 18 package org.apache.geronimo.interop.generator; 19 20 import java.util.Vector ; 21 22 public class JSwitchStatement extends JStatement { 23 private JExpression switchExpr; 24 private Vector caseStatements; 25 26 public JSwitchStatement(JExpression e) { 27 switchExpr = e; 28 caseStatements = new Vector (); 29 } 30 31 public void setVariable(JExpression e) { 32 switchExpr = e; 33 } 34 35 public JExpression getExpression() { 36 return switchExpr; 37 } 38 39 public JCaseStatement getCase(JExpression e) { 40 JCaseStatement rc = null; 41 int index = caseStatements.indexOf(e); 42 43 if (index >= 0) { 44 rc = (JCaseStatement) caseStatements.get(index); 45 } 46 47 return rc; 48 } 49 50 public JCaseStatement newCase(JExpression e) { 51 JCaseStatement rc = getCase(e); 52 53 if (rc == null) { 54 rc = new JCaseStatement(e); 55 caseStatements.add(rc); 56 } 57 58 return rc; 59 } 60 61 public void addCaseStatement(JExpression e, JStatement s) { 62 JCaseStatement cs = getCase(e); 63 64 if (cs == null) { 65 cs = newCase(e); 66 } 67 68 cs.addStatement(s); 69 } 70 71 public Vector getCases() { 72 return caseStatements; 73 } 74 } 75 | Popular Tags |