*** empty log message ***
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / ast / Case.java
1 package net.sourceforge.phpdt.internal.compiler.ast;
2
3 import java.util.List;
4
5 /**
6  * A Case statement for a Switch.
7  * @author Matthieu Casanova
8  */
9 public class Case extends AbstractCase {
10
11   public Expression value;
12
13   public Case(final Expression value,
14               final Statement[] statements,
15               final int sourceStart,
16               final int sourceEnd) {
17     super(statements, sourceStart, sourceEnd);
18     this.value = value;
19   }
20
21   /**
22    * Return the object into String.
23    * @param tab how many tabs (not used here
24    * @return a String
25    */
26   public String toString(final int tab) {
27     final StringBuffer buff = new StringBuffer(tabString(tab));
28     buff.append("case ");
29     buff.append(value.toStringExpression());
30     buff.append(" :\n");
31     if (statements != null) {
32       for (int i = 0; i < statements.length; i++) {
33         final Statement statement = statements[i];
34         buff.append(statement.toString(tab + 1));
35       }
36     }
37     return buff.toString();
38   }
39
40   /**
41    * get the modified variables.
42    * @return the variables from we change value
43    */
44   public List getModifiedVariable() {
45     final List list = super.getModifiedVariable();
46     list.addAll(value.getModifiedVariable());
47     return list;
48   }
49
50   /**
51    * Get the variables used.
52    * @return the variables used
53    */
54   public List getUsedVariable() {
55     final List list = super.getUsedVariable();
56     list.addAll(value.getUsedVariable());
57     return list;
58   }
59 }