1 package net.sourceforge.phpdt.internal.compiler.ast;
4 import java.util.ArrayList;
7 * @author Matthieu Casanova
9 public class SwitchStatement extends Statement {
11 public Expression variable;
12 public AbstractCase[] cases;
14 public SwitchStatement(final Expression variable,
15 final AbstractCase[] cases,
16 final int sourceStart,
17 final int sourceEnd) {
18 super(sourceStart, sourceEnd);
19 this.variable = variable;
24 * Return the object into String.
25 * @param tab how many tabs (not used here
28 public String toString(final int tab) {
29 final StringBuffer buff = new StringBuffer(tabString(tab));
30 buff.append("switch (").append(variable.toStringExpression()).append(") {\n");
31 for (int i = 0; i < cases.length; i++) {
32 final AbstractCase cas = cases[i];
33 buff.append(cas.toString(tab + 1));
37 return buff.toString();
41 * Get the variables from outside (parameters, globals ...)
43 public void getOutsideVariable(final List list) {
44 for (int i = 0; i < cases.length; i++) {
45 cases[i].getOutsideVariable(list);
50 * get the modified variables.
52 public void getModifiedVariable(final List list) {
53 for (int i = 0; i < cases.length; i++) {
54 cases[i].getModifiedVariable(list);
56 variable.getModifiedVariable(list);
60 * Get the variables used.
62 public void getUsedVariable(final List list) {
63 for (int i = 0; i < cases.length; i++) {
64 cases[i].getUsedVariable(list);
66 variable.getUsedVariable(list);