content
Declarations and statements contained in this block.
Either
JStatement
or JDeclaration
.JGenerable
, JStatement
JBlock
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.
private boolean
private boolean
private int
void
_break()
void
void
void
_do(JExpression test)
_for()
_if(JExpression expr)
void
_return()
void
_return(JExpression exp)
_switch(JExpression test)
void
_throw(JExpression exp)
_try()
_while(JExpression test)
add(JStatement s)
assign(JAssignmentTarget lhs,
JExpression exp)
assignPlus(JAssignmentTarget lhs,
JExpression exp)
block()
decl(int mods,
JType type,
String name,
JExpression init)
decl(JType type,
String name,
JExpression init)
directStatement(String source)
forEach(JType varType,
String name,
JExpression collection)
void
(package private) void
JStatement
s and JDeclaration
in this block.private <T> T
insert(T statementOrDeclaration)
invoke(JExpression expr,
JMethod method)
invoke(JExpression expr,
String method)
boolean
isEmpty()
continue
and break
statements.int
pos()
int
pos(int newPos)
void
state(JFormatter f)
staticInvoke(JClass type,
String method)
JStatement
or JDeclaration
.JStatement
s and JDeclaration
in this block.IllegalArgumentException
- if the new position value is illegal.type
- JType of the variablename
- Name of the variabletype
- JType of the variablename
- Name of the variableinit
- Initialization expression for this variable. May be null.mods
- Modifiers for the variabletype
- JType of the variablename
- Name of the variableinit
- Initialization expression for this variable. May be null.lhs
- Assignable variable or field for left hand side of expressionexp
- Right hand side expressionexpr
- JExpression evaluating to the class or object upon which
the named method will be invokedmethod
- Name of method to invokeexpr
- JExpression evaluating to the class or object upon which
the method will be invokedmethod
- JMethod to invokemethod
- Name of method to invokemethod
- JMethod to invokes
- JStatement to be addedexpr
- JExpression to be tested to determine branchingcontinue
and break
statements.Specified string is printed as-is. This is useful as a short-cut.
For example, you can invoke this method as:
directStatement("a=b+c;")
.
generate
in interface JGenerable
state
in interface JStatement