uk.co.badgersinfoil.metaas
Interface StatementContainer

All Known Subinterfaces:
ASBlock, ASIfStatement, ASMethod

public interface StatementContainer

Defines the common services provided by structures which can contain ActionScript 'statements'.


Method Summary
 void addComment(java.lang.String text)
          Adds a single-line comment to list of statements being generated
 void addStmt(java.lang.String statement)
          Checks the syntax of the given code, and then adds the statement to the end of the current block.
 boolean containsCode()
          Returns true if if this container currently contains at least one statement, and false if it is empty, or contains only comments and whitespace.
 StatementContainer newDoWhile(java.lang.String condition)
          Adds a do-while-loop to the code.
 StatementContainer newFor(java.lang.String init, java.lang.String condition, java.lang.String update)
          Adds a C-style for-loop to the code.
 StatementContainer newForEachIn(java.lang.String init, java.lang.String list)
           
 StatementContainer newForIn(java.lang.String init, java.lang.String list)
          Adds a for-in-loop to the code.
 ASIfStatement newIf(java.lang.String condition)
          Adds an if-statement to the code.
 ASSwitchStatement newSwitch(java.lang.String condition)
          Adds a switch-statement to the code.
 StatementContainer newWhile(java.lang.String condition)
          Adds a while-loop to the code.
 

Method Detail

addStmt

void addStmt(java.lang.String statement)
Checks the syntax of the given code, and then adds the statement to the end of the current block.

Throws:
SyntaxException - if the syntax of the given code fragment is incorrect.

addComment

void addComment(java.lang.String text)
Adds a single-line comment to list of statements being generated

Parameters:
text - the text of the comment (minus the initial '//') which must not include any newline characters.

newIf

ASIfStatement newIf(java.lang.String condition)
Adds an if-statement to the code. e.g.
block.newIf("test()").addStmt("trace('success')")
results in
 if (test()) {
        trace('success');
 }


newFor

StatementContainer newFor(java.lang.String init,
                          java.lang.String condition,
                          java.lang.String update)
Adds a C-style for-loop to the code. e.g.
block.newFor("var i=0", "i<10", "i++").addStmt("trace(i)")
results in
 for (var i=0; i<10; i++) {
        trace(i);
 }


newForIn

StatementContainer newForIn(java.lang.String init,
                            java.lang.String list)
Adds a for-in-loop to the code. e.g.
block.newForIn("var i", "myArray").addStmt("trace(i)")
results in
 for (var i in myArray) {
        trace(i);
 }


newForEachIn

StatementContainer newForEachIn(java.lang.String init,
                                java.lang.String list)

newWhile

StatementContainer newWhile(java.lang.String condition)
Adds a while-loop to the code. e.g.
block.newWhile("test()").addStmt("trace('hi there')")
results in
 while (test()) {
        trace('hi there');
 }


newDoWhile

StatementContainer newDoWhile(java.lang.String condition)
Adds a do-while-loop to the code. e.g.
block.newDoWhile("test()").addStmt("trace('hi there')")
results in
 do {
        trace('hi there');
 } while (test());


newSwitch

ASSwitchStatement newSwitch(java.lang.String condition)
Adds a switch-statement to the code. See ASSwitchStatement for more information.


containsCode

boolean containsCode()
Returns true if if this container currently contains at least one statement, and false if it is empty, or contains only comments and whitespace.



Copyright © 2006 null. All Rights Reserved.