uk.co.badgersinfoil.metaas.dom
Interface ASIfStatement

All Superinterfaces:
Statement, StatementContainer

public interface ASIfStatement
extends Statement, StatementContainer

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

getElse

ASBlock getElse()
Returns a reference to an object which can populate the else-clause of this ActionScript if-statement with new code.


setThen

void setThen(ASBlock thenBlock)

getConditionString

java.lang.String getConditionString()
Returns a string representation of the condition-expression for this if-statement. e.g. for the expression if (test()) { }, this method will return the string "test()".


setCondition

void setCondition(java.lang.String string)
Changes the condition-expression for this if-statement.

Throws:
SyntaxException - if the given string is not a valid ActionScript expression.


Copyright © 2006-2007 David Holroyd. All Rights Reserved.