1 package net.sourceforge.phpdt.internal.compiler.ast;
6 * @author Matthieu Casanova
8 public class SwitchStatement extends Statement {
10 public Expression variable;
11 public AbstractCase[] cases;
13 public SwitchStatement(final Expression variable,
14 final AbstractCase[] cases,
15 final int sourceStart,
16 final int sourceEnd) {
17 super(sourceStart, sourceEnd);
18 this.variable = variable;
23 * Return the object into String.
24 * @param tab how many tabs (not used here
27 public String toString(final int tab) {
28 final StringBuffer buff = new StringBuffer(tabString(tab));
29 buff.append("switch (").append(variable.toStringExpression()).append(") {\n");
30 for (int i = 0; i < cases.length; i++) {
31 final AbstractCase cas = cases[i];
32 buff.append(cas.toString(tab + 1));
36 return buff.toString();
40 * Get the variables from outside (parameters, globals ...)
42 public void getOutsideVariable(final List list) {
43 for (int i = 0; i < cases.length; i++) {
44 cases[i].getOutsideVariable(list);
49 * get the modified variables.
51 public void getModifiedVariable(final List list) {
52 for (int i = 0; i < cases.length; i++) {
53 cases[i].getModifiedVariable(list);
55 variable.getModifiedVariable(list);
59 * Get the variables used.
61 public void getUsedVariable(final List list) {
62 for (int i = 0; i < cases.length; i++) {
63 cases[i].getUsedVariable(list);
65 variable.getUsedVariable(list);