1 package net.sourceforge.phpdt.internal.compiler.ast;
6 * @author Matthieu Casanova
8 public final class SwitchStatement extends Statement {
10 private final Expression variable;
11 private final 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 * @param list the list where we will put variables
44 public void getOutsideVariable(final List list) {
45 for (int i = 0; i < cases.length; i++) {
46 cases[i].getOutsideVariable(list);
51 * get the modified variables.
53 * @param list the list where we will put variables
55 public void getModifiedVariable(final List list) {
56 for (int i = 0; i < cases.length; i++) {
57 cases[i].getModifiedVariable(list);
59 variable.getModifiedVariable(list);
63 * Get the variables used.
65 * @param list the list where we will put variables
67 public void getUsedVariable(final List list) {
68 for (int i = 0; i < cases.length; i++) {
69 cases[i].getUsedVariable(list);
71 variable.getUsedVariable(list);