1 package net.sourceforge.phpdt.internal.compiler.ast;
4 import java.util.ArrayList;
7 * A ConditionalExpression is like that : booleanExpression ? trueValue : falseValue;
8 * @author Matthieu Casanova
10 public class ConditionalExpression extends OperatorExpression {
12 public Expression condition, valueIfTrue, valueIfFalse;
14 public ConditionalExpression(final Expression condition,
15 final Expression valueIfTrue,
16 final Expression valueIfFalse) {
17 super(-1, condition.sourceStart, valueIfFalse.sourceEnd);
18 this.condition = condition;
19 this.valueIfTrue = valueIfTrue;
20 this.valueIfFalse = valueIfFalse;
23 public String toStringExpression() {
24 final StringBuffer buff = new StringBuffer("(");
25 buff.append(condition.toStringExpression());
27 buff.append(valueIfTrue.toStringExpression());
29 buff.append(valueIfFalse.toStringExpression());
30 return buff.toString();
34 * Get the variables from outside (parameters, globals ...)
35 * @return the variables from outside
37 public List getOutsideVariable() {
38 return new ArrayList();
42 * get the modified variables.
43 * @return the variables from we change value
45 public List getModifiedVariable() {
46 final ArrayList list = new ArrayList();
47 list.addAll(condition.getModifiedVariable());
48 list.addAll(valueIfTrue.getModifiedVariable());
49 list.addAll(valueIfFalse.getModifiedVariable());
54 * Get the variables used.
55 * @return the variables used
57 public List getUsedVariable() {
58 final ArrayList list = new ArrayList();
59 list.addAll(condition.getUsedVariable());
60 list.addAll(valueIfTrue.getUsedVariable());
61 list.addAll(valueIfFalse.getUsedVariable());