All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class openjava.ptree.ConditionalExpression

java.lang.Object
   |
   +----openjava.ptree.PtreeObject
           |
           +----openjava.ptree.NonLeaf
                   |
                   +----openjava.ptree.ConditionalExpression

public class ConditionalExpression
extends NonLeaf
implements Expression
The ConditionalExpression class represents a conditional expression like:
     (i == 1) ? 3 : 4
 

This consists of a conditional part, true case part, and false case part. Each part of them is an expression.
If the operator in the expression of the operands has week unity, this automatically produces the code in which the operands are enclosed by parenthesises.
In the case the conditional part is f = f(), the true case part is "red" and the false case part is str = "blue" this produces the code :
     (f = f()) ? "red" : (str = "blue")
 

See Also:
Expression

Constructor Index

 o ConditionalExpression(Expression, Expression, Expression)
Allocates a new conditional expression object.

Method Index

 o getCondition()
Gets the conditional part of this conditional expression.
 o getFalseCase()
Gets the false case part of this.
 o getTrueCase()
Gets the true case part of this conditional expression.
 o setCondition(Expression)
Sets the conditional part of this conditional expression.
 o setFalseCase(Expression)
Sets the false case part of this.
 o setTrueCase(Expression)
Sets the true case part of this conditional expression.
 o writeCode()
Writes the code this parse-tree presents for.

Constructors

 o ConditionalExpression
 public ConditionalExpression(Expression condition,
                              Expression truecase,
                              Expression falsecase)
Allocates a new conditional expression object.

Parameters:
condition - the conditional part of this expression.
truecase - the expression to be evaluated when conditional part is true.
falsecase - the expression to be evaluated when conditional part is false.

Methods

 o writeCode
 public void writeCode()
Writes the code this parse-tree presents for.

Overrides:
writeCode in class NonLeaf
 o getCondition
 public Expression getCondition()
Gets the conditional part of this conditional expression.

Returns:
the expression of this conditional part.
 o setCondition
 public void setCondition(Expression expr)
Sets the conditional part of this conditional expression.

Parameters:
expr - the expression to set as this conditional part.
 o getTrueCase
 public Expression getTrueCase()
Gets the true case part of this conditional expression.

Returns:
the expression of this true case part.
 o setTrueCase
 public void setTrueCase(Expression expr)
Sets the true case part of this conditional expression.

Parameters:
expr - the expression to set as this true part.
 o getFalseCase
 public Expression getFalseCase()
Gets the false case part of this.

Returns:
the expression of this false case part.
 o setFalseCase
 public void setFalseCase(Expression expr)
Sets the false case part of this.

Parameters:
expr - the expression to set as this false part.

All Packages  Class Hierarchy  This Package  Previous  Next  Index