1 package net.sourceforge.phpdt.internal.compiler.ast;
4 * This is a if statement.
9 * @author Matthieu Casanova
11 public class IfStatement extends Statement {
13 public Expression condition;
14 public Statement statement;
15 public ElseIf[] elseifs;
19 * Create a new If statement
20 * @param condition the condition
21 * @param statement a statement or a block of statements
22 * @param elseifs the elseifs
23 * @param els the else (or null)
24 * @param sourceStart the starting position
25 * @param sourceEnd the ending offset
27 public IfStatement(Expression condition,
33 super(sourceStart, sourceEnd);
34 this.condition = condition;
35 this.statement = statement;
36 this.elseifs = elseifs;
41 * Return the object into String.
42 * @param tab how many tabs (not used here
45 public String toString(int tab) {
46 final StringBuffer buff = new StringBuffer(tabString(tab));
48 buff.append(condition.toStringExpression()).append(") ");
50 buff.append(statement.toString(tab+1));
51 for (int i = 0; i < elseifs.length; i++) {
52 ElseIf elseif = elseifs[i];
53 buff.append(elseif.toString(tab+1));
57 buff.append(els.toString(tab+1));
60 return buff.toString();