|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--openjava.ptree.ParseTreeObject | +--openjava.ptree.NonLeaf | +--openjava.ptree.ConditionalExpression
The ConditionalExpression
class represents
a conditional expression like:
(i == 1) ? 3 : 4
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")
Expression
Fields inherited from class openjava.ptree.ParseTreeObject |
debugFlag,
debugLevel,
LN,
out,
writerStack |
Constructor Summary | |
ConditionalExpression(Expression condition,
Expression truecase,
Expression falsecase)
Allocates a new conditional expression object. |
Method Summary | |
void |
accept(ParseTreeVisitor v)
Accepts a ParseTreeVisitor object as the role of a
Visitor in the Visitor pattern, as the role of an Element in the
Visitor pattern. |
Expression |
getCondition()
Gets the conditional part of this conditional expression. |
Expression |
getFalseCase()
Gets the false case part of this. |
Expression |
getTrueCase()
Gets the true case part of this conditional expression. |
OJClass |
getType(Environment env)
|
void |
setCondition(Expression expr)
Sets the conditional part of this conditional expression. |
void |
setFalseCase(Expression expr)
Sets the false case part of this. |
void |
setTrueCase(Expression expr)
Sets the true case part of this conditional expression. |
void |
writeCode()
Writes the code this parse-tree presents for. |
Methods inherited from class openjava.ptree.NonLeaf |
childrenAccept,
elementAt,
equals,
getComment,
getContents,
getLength,
makeRecursiveCopy,
replaceChildWith,
set,
set,
set,
set,
set,
set,
set,
set,
set,
setComment,
setElementAt |
Methods inherited from class openjava.ptree.ParseTreeObject |
clone,
eq,
eq,
equal,
flushPrintWriter,
getDebugFlag,
getNest,
getObjectID,
getParent,
getPrintWriter,
getTab,
hashCode,
lastObjectID,
makeCopy,
popNest,
popPrintWriter,
pushNest,
pushPrintWriter,
replace,
setDebugFlag,
setDebugLevel,
setNest,
setParent,
setPrintStream,
setTab,
toFlattenString,
toString,
writeDebug,
writeDebugL,
writeDebugLln,
writeDebugln,
writeDebugLR,
writeDebugR,
writeDebugRln,
writeTab |
Methods inherited from class java.lang.Object |
equals,
finalize,
getClass,
notify,
notifyAll,
wait,
wait,
wait |
Constructor Detail |
public ConditionalExpression(Expression condition, Expression truecase, Expression falsecase)
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.Method Detail |
public void writeCode()
public Expression getCondition()
public void setCondition(Expression expr)
expr
- the expression to set as this conditional part.public Expression getTrueCase()
public void setTrueCase(Expression expr)
expr
- the expression to set as this true part.public Expression getFalseCase()
public void setFalseCase(Expression expr)
expr
- the expression to set as this false part.public void accept(ParseTreeVisitor v) throws ParseTreeException
ParseTreeVisitor
object as the role of a
Visitor in the Visitor pattern, as the role of an Element in the
Visitor pattern.
This invoke an appropriate visit()
method on the
accepted visitor.
visitor
- a visitorpublic OJClass getType(Environment env) throws java.lang.Exception
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |