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 ...)
42 * @return the variables from outside
44 public List getOutsideVariable() {
45 final ArrayList list = new ArrayList();
46 for (int i = 0; i < cases.length; i++) {
47 list.addAll(cases[i].getOutsideVariable());
53 * get the modified variables.
54 * @return the variables modified
56 public List getModifiedVariable() {
57 final ArrayList list = new ArrayList();
58 for (int i = 0; i < cases.length; i++) {
59 list.addAll(cases[i].getModifiedVariable());
61 list.addAll(variable.getModifiedVariable());
66 * Get the variables used.
67 * @return the variables used
69 public List getUsedVariable() {
70 final ArrayList list = new ArrayList();
71 for (int i = 0; i < cases.length; i++) {
72 list.addAll(cases[i].getUsedVariable());
74 list.addAll(variable.getUsedVariable());