|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
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. |
java.util.List |
getStatementList()
Returns a list of the statements held in the containing element. |
ASDeclarationStatement |
newDeclaration(java.lang.String assignment)
Adds a new variable declaration to the code, and returns a reference to it. |
ASDoWhileStatement |
newDoWhile(java.lang.String condition)
Adds a do-while-loop to the code. |
ASExpressionStatement |
newExprStmt(java.lang.String expr)
Adds a new expression-statement to the code, and returns a reference to it. |
ASForStatement |
newFor(java.lang.String init,
java.lang.String condition,
java.lang.String update)
Adds a C-style for-loop to the code. |
ASForEachInStatement |
newForEachIn(java.lang.String init,
java.lang.String list)
|
ASForInStatement |
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. |
ASReturnStatement |
newReturn(java.lang.String expr)
Adds a new return-statement to the code (with optional return expression), and returns a reference to it. |
ASSwitchStatement |
newSwitch(java.lang.String condition)
Adds a switch-statement to the code. |
ASWhileStatement |
newWhile(java.lang.String condition)
Adds a while-loop to the code. |
ASWithStatement |
newWith(java.lang.String string)
Adds a new with-statement to the code, and returns a reference to it. |
Method Detail |
---|
void addStmt(java.lang.String statement)
SyntaxException
- if the syntax of the given code fragment is
incorrect.ASExpressionStatement newExprStmt(java.lang.String expr)
void addComment(java.lang.String text)
text
- the text of the comment (minus the initial '//') which
must not include any newline characters.ASIfStatement newIf(java.lang.String condition)
block.newIf("test()").addStmt("trace('success')")results in
if (test()) { trace('success'); }
ASForStatement newFor(java.lang.String init, java.lang.String condition, java.lang.String update)
block.newFor("var i=0", "i<10", "i++").addStmt("trace(i)")results in
for (var i=0; i<10; i++) { trace(i); }
ASForInStatement newForIn(java.lang.String init, java.lang.String list)
block.newForIn("var i", "myArray").addStmt("trace(i)")results in
for (var i in myArray) { trace(i); }
ASForEachInStatement newForEachIn(java.lang.String init, java.lang.String list)
ASWhileStatement newWhile(java.lang.String condition)
block.newWhile("test()").addStmt("trace('hi there')")results in
while (test()) { trace('hi there'); }
ASDoWhileStatement newDoWhile(java.lang.String condition)
block.newDoWhile("test()").addStmt("trace('hi there')")results in
do { trace('hi there'); } while (test());
ASSwitchStatement newSwitch(java.lang.String condition)
ASSwitchStatement
for more information.
ASWithStatement newWith(java.lang.String string)
method.newWith("value").addStmt("trace(test)");
results in,
with (value) { trace(test); }
ASDeclarationStatement newDeclaration(java.lang.String assignment)
method.newDeclaration("a=1");
results in,
var a=1;
ASReturnStatement newReturn(java.lang.String expr)
method.newReturn(null);
results in a plain return statement,
return;
Whereas passing an expression,
method.newReturn("theVal()");
results will cause that expression to be returned,
return theVal();
boolean containsCode()
java.util.List getStatementList()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |