|
||||||||||
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'.
Some elements in the metaas DOM extend StatementContainer while they are not strictly containers for multiple statements. This is a convinience for the common case where the element in question usually appears with an attached block-statement. So, for example, rather than writing...
List stmts = ((ASBlock)ifStmt.getThenStatement()).getStatementList();
...we can instead write...
List stmts = ifStmt.getStatementList();If, in the above example, the 'then-clause' of the ASIfStatement was not actually a block, a SyntaxException would be raised.
Method Summary | |
---|---|
void |
addComment(java.lang.String text)
Adds a single-line comment to list of statements being generated |
Statement |
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 Statement objects held in the
containing element. |
ASBreakStatement |
newBreak()
Creates a new break statement. |
ASContinueStatement |
newContinue()
|
ASDeclarationStatement |
newDeclaration(Expression assignment)
|
ASDeclarationStatement |
newDeclaration(java.lang.String assignment)
Adds a new variable declaration to the code, and returns a reference to it. |
ASDefaultXMLNamespaceStatement |
newDefaultXMLNamespace(java.lang.String namespace)
|
ASDoWhileStatement |
newDoWhile(Expression condition)
|
ASDoWhileStatement |
newDoWhile(java.lang.String condition)
Adds a do-while-loop to the code. |
ASExpressionStatement |
newExprStmt(Expression expr)
|
ASExpressionStatement |
newExprStmt(java.lang.String expr)
Adds a new expression-statement to the code, and returns a reference to it. |
ASForStatement |
newFor(Expression init,
Expression condition,
Expression update)
|
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(Expression init,
Expression list)
|
ASForEachInStatement |
newForEachIn(java.lang.String init,
java.lang.String list)
|
ASForInStatement |
newForIn(Expression init,
Expression list)
|
ASForInStatement |
newForIn(java.lang.String init,
java.lang.String list)
Adds a for-in-loop to the code. |
ASIfStatement |
newIf(Expression condition)
|
ASIfStatement |
newIf(java.lang.String condition)
Adds an if-statement to the code. |
ASReturnStatement |
newReturn()
|
ASReturnStatement |
newReturn(Expression expr)
|
ASReturnStatement |
newReturn(java.lang.String expr)
Adds a new return-statement to the code (with optional return expression), and returns a reference to it. |
ASSuperStatement |
newSuper(java.util.List arguments)
Adds a call to the superclass constructor (assuming that this is itself a constructor). |
ASSwitchStatement |
newSwitch(Expression condition)
|
ASSwitchStatement |
newSwitch(java.lang.String condition)
Adds a switch-statement to the code. |
ASThrowStatement |
newThrow(Expression t)
|
ASTryStatement |
newTryCatch(java.lang.String var,
java.lang.String type)
|
ASTryStatement |
newTryFinally()
|
ASWhileStatement |
newWhile(Expression condition)
|
ASWhileStatement |
newWhile(java.lang.String condition)
Adds a while-loop to the code. |
ASWithStatement |
newWith(Expression string)
|
ASWithStatement |
newWith(java.lang.String string)
Adds a new with-statement to the code, and returns a reference to it. |
Method Detail |
---|
Statement addStmt(java.lang.String statement)
SyntaxException
- if the syntax of the given code fragment is
incorrect.ASExpressionStatement newExprStmt(java.lang.String expr)
ASExpressionStatement newExprStmt(Expression 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'); }
ASIfStatement newIf(Expression condition)
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); }
ASForStatement newFor(Expression init, Expression condition, Expression update)
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); }
ASForInStatement newForIn(Expression init, Expression list)
ASForEachInStatement newForEachIn(java.lang.String init, java.lang.String list)
ASForEachInStatement newForEachIn(Expression init, Expression list)
ASWhileStatement newWhile(java.lang.String condition)
block.newWhile("test()").addStmt("trace('hi there')")results in
while (test()) { trace('hi there'); }
ASWhileStatement newWhile(Expression condition)
ASDoWhileStatement newDoWhile(java.lang.String condition)
block.newDoWhile("test()").addStmt("trace('hi there')")results in
do { trace('hi there'); } while (test());
ASDoWhileStatement newDoWhile(Expression condition)
ASSwitchStatement newSwitch(java.lang.String condition)
ASSwitchStatement
for more information.
ASSwitchStatement newSwitch(Expression condition)
ASWithStatement newWith(java.lang.String string)
method.newWith("value").addStmt("trace(test)");
results in,
with (value) { trace(test); }
ASWithStatement newWith(Expression string)
ASDeclarationStatement newDeclaration(java.lang.String assignment)
method.newDeclaration("a=1");
results in,
var a=1;
ASDeclarationStatement newDeclaration(Expression assignment)
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();
ASReturnStatement newReturn(Expression expr)
ASReturnStatement newReturn()
ASSuperStatement newSuper(java.util.List arguments)
ASBreakStatement newBreak()
break
statement.
ASTryStatement newTryCatch(java.lang.String var, java.lang.String type)
ASTryStatement newTryFinally()
ASContinueStatement newContinue()
ASThrowStatement newThrow(Expression t)
ASDefaultXMLNamespaceStatement newDefaultXMLNamespace(java.lang.String namespace)
boolean containsCode()
java.util.List getStatementList()
Statement
objects held in the
containing element. The list is immutable (entries cannnot be
added, removed or replaced) but the objects obtained from the list
my be modified via the methods they provide.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |