Some minor changes
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / ast / ElseIf.java
1 package net.sourceforge.phpdt.internal.compiler.ast;
2
3 import java.util.List;
4
5 /**
6  * An elseif statement.
7  * @author Matthieu Casanova
8  */
9 public final class ElseIf extends Statement {
10
11   /** The condition. */
12   private final Expression condition;
13
14   /** The statements. */
15   private final Statement[] statements;
16
17   public ElseIf(final Expression condition, final Statement[] statements, final int sourceStart, final int sourceEnd) {
18     super(sourceStart, sourceEnd);
19     this.condition = condition;
20     this.statements = statements;
21   }
22
23   /**
24    * Return the object into String.
25    * @param tab how many tabs (not used here
26    * @return a String
27    */
28   public String toString(final int tab) {
29     final StringBuffer buff = new StringBuffer(tabString(tab));
30     buff.append("elseif (");
31     buff.append(condition.toStringExpression());
32     buff.append(") \n");
33     for (int i = 0; i < statements.length; i++) {
34       final Statement statement = statements[i];
35       buff.append(statement.toString(tab + 1)).append('\n');
36     }
37     return buff.toString();
38   }
39
40   /**
41    * Get the variables from outside (parameters, globals ...)
42    *
43    * @param list the list where we will put variables
44    */
45   public void getOutsideVariable(final List list) {
46     for (int i = 0; i < statements.length; i++) {
47       statements[i].getModifiedVariable(list);
48     }
49   }
50
51   /**
52    * get the modified variables.
53    *
54    * @param list the list where we will put variables
55    */
56   public void getModifiedVariable(final List list) {
57     for (int i = 0; i < statements.length; i++) {
58       statements[i].getModifiedVariable(list);
59     }
60     condition.getModifiedVariable(list);
61   }
62
63   /**
64    * Get the variables used.
65    *
66    * @param list the list where we will put variables
67    */
68   public void getUsedVariable(final List list) {
69     for (int i = 0; i < statements.length; i++) {
70       statements[i].getUsedVariable(list);
71     }
72     condition.getUsedVariable(list);
73   }
74 }