|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface ASIfStatement
Obtained from StatementContainer.newIf(String)
, an ASIfStatement
allows statements to be added to the 'then' and else' branches.
e.g. To simply add statements to the 'then' branch (executed when the condition holds true),
ASIfStatement ifStmt = method.newIf("test()"); isStmt.addStmt("trace('test succeeded')");
will result in ActionScript code like,
if (test()) { trace('test succeeded'); }
To add code to both 'then' and 'else' branches,
ASIfStatement ifStmt = method.newIf("test()"); isStmt.addStmt("trace('test succeeded')"); ifStmt.getElse().addStmt("trace('test failed')");
will result in ActionScript code like,
if (test()) { trace('test succeeded'); } else { trace('test failed'); }
Note that the first call to getElse() will cause the else-block to be created (even if no statements are subsequently added to it). Subsequent calls to getElse() will return references to the same else-block.
Method Summary | |
---|---|
java.lang.String |
getConditionString()
Returns a string representation of the condition-expression for this if-statement. |
ASBlock |
getElse()
Returns a reference to an object which can populate the else-clause of this ActionScript if-statement with new code. |
void |
setCondition(java.lang.String string)
Changes the condition-expression for this if-statement. |
void |
setThen(ASBlock thenBlock)
|
Methods inherited from interface uk.co.badgersinfoil.metaas.dom.StatementContainer |
---|
addComment, addStmt, containsCode, getStatementList, newDeclaration, newDoWhile, newExprStmt, newFor, newForEachIn, newForIn, newIf, newReturn, newSwitch, newWhile, newWith |
Method Detail |
---|
ASBlock getElse()
void setThen(ASBlock thenBlock)
java.lang.String getConditionString()
if (test()) { }
, this method will return the string
"test()"
.
void setCondition(java.lang.String string)
SyntaxException
- if the given
string is not a valid ActionScript expression.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |