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(") ");
49 buff.append(statement.toString(tab+1));
50 for (int i = 0; i < elseifs.length; i++) {
51 buff.append(elseifs[i].toString(tab+1));
55 buff.append(els.toString(tab+1));
58 return buff.toString();