|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.mule.devkit.model.code.GeneratedBlock
public final class GeneratedBlock
A block of Java code, which may contain statements and local declarations.
GeneratedBlock contains a large number of factory methods that creates new
statements/declarations. Those newly created statements/declarations are
inserted into the "current position". The position advances
one every time you add a new instruction.
| Constructor Summary | |
|---|---|
GeneratedBlock()
|
|
GeneratedBlock(boolean bracesRequired,
boolean indentRequired)
|
|
| Method Summary | |
|---|---|
void |
_break()
Create a break statement and add it to this block |
void |
_break(GeneratedLabel label)
|
void |
_continue()
|
void |
_continue(GeneratedLabel label)
Create a continue statement and add it to this block |
GeneratedDoLoop |
_do(GeneratedExpression test)
Create a Do statement and add it to this block |
GeneratedForLoop |
_for()
Create a For statement and add it to this block |
GeneratedConditional |
_if(GeneratedExpression expr)
Create an If statement and add it to this block |
void |
_return()
Create a return statement and add it to this block |
void |
_return(GeneratedExpression exp)
Create a return statement and add it to this block |
GeneratedSwitch |
_switch(GeneratedExpression test)
Create a switch/case statement and add it to this block |
void |
_throw(GeneratedExpression exp)
Create a throw statement and add it to this block |
GeneratedTry |
_try()
Create a Try statement and add it to this block |
GeneratedWhileLoop |
_while(GeneratedExpression test)
Create a While statement and add it to this block |
GeneratedBlock |
add(Statement s)
Adds a statement to this block |
GeneratedBlock |
assign(AssignmentTarget lhs,
GeneratedExpression exp)
Creates an assignment statement and adds it to this block. |
GeneratedBlock |
assignPlus(AssignmentTarget lhs,
GeneratedExpression exp)
|
GeneratedBlock |
block()
Create a sub-block and add it to this block |
GeneratedVariable |
decl(int mods,
Type type,
String name,
GeneratedExpression init)
Adds a local variable declaration to this block |
GeneratedVariable |
decl(Type type,
String name)
Adds a local variable declaration to this block |
GeneratedVariable |
decl(Type type,
String name,
GeneratedExpression init)
Adds a local variable declaration to this block |
Statement |
directStatement(String source)
Creates a "literal" statement directly. |
GeneratedForEach |
forEach(Type varType,
String name,
GeneratedExpression collection)
Creates an enhanced For statement based on j2se 1.5 JLS and add it to this block |
void |
generate(Formatter f)
|
List<Object> |
getContents()
Returns a read-only view of Statements and Declaration
in this block. |
GeneratedInvocation |
invoke(GeneratedExpression expr,
GeneratedMethod method)
Creates an invocation statement and adds it to this block. |
GeneratedInvocation |
invoke(GeneratedExpression expr,
String method)
Creates an invocation statement and adds it to this block. |
GeneratedInvocation |
invoke(GeneratedMethod method)
Creates an invocation statement and adds it to this block. |
GeneratedInvocation |
invoke(String method)
Creates an invocation statement and adds it to this block. |
boolean |
isEmpty()
Returns true if this block is empty and does not contain any statement. |
GeneratedLabel |
label(String name)
Create a label, which can be referenced from continue and break statements. |
int |
pos()
Gets the current position to which new statements will be inserted. |
int |
pos(int newPos)
Sets the current position. |
void |
state(Formatter f)
|
GeneratedInvocation |
staticInvoke(TypeReference type,
String method)
Creates a static invocation statement. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public GeneratedBlock()
public GeneratedBlock(boolean bracesRequired,
boolean indentRequired)
| Method Detail |
|---|
public List<Object> getContents()
Statements and Declaration
in this block.
public int pos()
pos(int)public int pos(int newPos)
IllegalArgumentException - if the new position value is illegal.pos()public boolean isEmpty()
public GeneratedVariable decl(Type type,
String name)
type - Type of the variablename - Name of the variable
public GeneratedVariable decl(Type type,
String name,
GeneratedExpression init)
type - Type of the variablename - Name of the variableinit - Initialization expression for this variable. May be null.
public GeneratedVariable decl(int mods,
Type type,
String name,
GeneratedExpression init)
mods - Modifiers for the variabletype - Type of the variablename - Name of the variableinit - Initialization expression for this variable. May be null.
public GeneratedBlock assign(AssignmentTarget lhs,
GeneratedExpression exp)
lhs - Assignable variable or field for left hand side of expressionexp - Right hand side expression
public GeneratedBlock assignPlus(AssignmentTarget lhs,
GeneratedExpression exp)
public GeneratedInvocation invoke(GeneratedExpression expr,
String method)
expr - Expression evaluating to the class or object upon which
the named method will be invokedmethod - Name of method to invoke
public GeneratedInvocation invoke(GeneratedExpression expr,
GeneratedMethod method)
expr - Expression evaluating to the class or object upon which
the method will be invokedmethod - Method to invoke
public GeneratedInvocation staticInvoke(TypeReference type,
String method)
public GeneratedInvocation invoke(String method)
method - Name of method to invoke
public GeneratedInvocation invoke(GeneratedMethod method)
method - Method to invoke
public GeneratedBlock add(Statement s)
s - Statement to be added
public GeneratedConditional _if(GeneratedExpression expr)
expr - Expression to be tested to determine branching
public GeneratedForLoop _for()
public GeneratedWhileLoop _while(GeneratedExpression test)
public GeneratedSwitch _switch(GeneratedExpression test)
public GeneratedDoLoop _do(GeneratedExpression test)
public GeneratedTry _try()
public void _return()
public void _return(GeneratedExpression exp)
public void _throw(GeneratedExpression exp)
public void _break()
public void _break(GeneratedLabel label)
public GeneratedLabel label(String name)
continue and break statements.
public void _continue(GeneratedLabel label)
public void _continue()
public GeneratedBlock block()
public Statement directStatement(String source)
directStatement("a=b+c;").
public void generate(Formatter f)
generate in interface Generable
public GeneratedForEach forEach(Type varType,
String name,
GeneratedExpression collection)
public void state(Formatter f)
state in interface Statement
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||