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.
| Modifier and Type | Field and Description |
|---|---|
| private boolean | bracesRequired
Whether or not this block must be braced and indented |
| private final List | content
Declarations and statements contained in this block. |
| private boolean | |
| private int | pos
Current position. |
| Access | Constructor and Description |
|---|---|
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public void | |
| public void | |
| public void | |
| public JDoLoop | Returns: Newly generated Do statementCreate a Do statement and add it to this block |
| public JForLoop | |
| public JConditional | Returns: Newly generated conditional statementJExpression to be tested to determine branching expr)Create an If statement and add it to this block |
| public void | |
| public void | |
| public JSwitch | |
| public void | |
| public JTryBlock | |
| public JWhileLoop | Returns: Newly generated While statementCreate a While statement and add it to this block |
| public JBlock | |
| public JBlock | assign(JAssignmentTarget
Assignable variable or field for left hand side of expression lhs, JExpression Right hand side expression exp)Creates an assignment statement and adds it to this block. |
| public JBlock | |
| public JBlock | |
| public JVar | |
| public JVar | Returns: Newly generated JVarJType of the variable type, String Name of the variable name, JExpression Initialization expression for this variable. May be null. init)Adds a local variable declaration to this block |
| public JVar | Returns: Newly generated JVarModifiers for the variable mods, JType JType of the variable type, String Name of the variable name, JExpression Initialization expression for this variable. May be null. init)Adds a local variable declaration to this block |
| public JStatement | |
| public JForEach | Returns: Newly generated enhanced For statement per j2se 1.5 specificationCreates an enhanced For statement based on j2se 1.5 JLS and add it to this block |
| public void | |
| pack-priv void | |
| public List | |
| private <T> T | |
| public JInvocation | Returns: Newly generated JInvocationJExpression evaluating to the class or object upon which
the named method will be invoked expr, String Name of method to invoke method)Creates an invocation statement and adds it to this block. |
| public JInvocation | Returns: Newly generated JInvocationJExpression evaluating to the class or object upon which
the method will be invoked expr, JMethod JMethod to invoke method)Creates an invocation statement and adds it to this block. |
| public JInvocation | |
| public JInvocation | |
| public boolean | |
| public JLabel | |
| public int | |
| public int | |
| public void | |
| public JInvocation |
| bracesRequired | back to summary |
|---|---|
| private boolean bracesRequired Whether or not this block must be braced and indented | |
| content | back to summary |
|---|---|
| private final List<Object> content Declarations and statements contained in this block.
Either | |
| indentRequired | back to summary |
|---|---|
| private boolean indentRequired | |
| pos | back to summary |
|---|---|
| private int pos Current position. | |
| JBlock | back to summary |
|---|---|
| public JBlock() | |
| JBlock | back to summary |
|---|---|
| public JBlock(boolean bracesRequired, boolean indentRequired) | |
| _break | back to summary |
|---|---|
| public void _break() Create a break statement and add it to this block | |
| _break | back to summary |
|---|---|
| public void _break(JLabel label) | |
| _continue | back to summary |
|---|---|
| public void _continue(JLabel label) Create a continue statement and add it to this block | |
| _continue | back to summary |
|---|---|
| public void _continue() | |
| _do | back to summary |
|---|---|
| public JDoLoop _do(JExpression test) Create a Do statement and add it to this block
| |
| _for | back to summary |
|---|---|
| public JForLoop _for() Create a For statement and add it to this block
| |
| _if | back to summary |
|---|---|
| public JConditional _if(JExpression expr) Create an If statement and add it to this block
| |
| _return | back to summary |
|---|---|
| public void _return() Create a return statement and add it to this block | |
| _return | back to summary |
|---|---|
| public void _return(JExpression exp) Create a return statement and add it to this block | |
| _switch | back to summary |
|---|---|
| public JSwitch _switch(JExpression test) Create a switch/case statement and add it to this block | |
| _throw | back to summary |
|---|---|
| public void _throw(JExpression exp) Create a throw statement and add it to this block | |
| _try | back to summary |
|---|---|
| public JTryBlock _try() Create a Try statement and add it to this block
| |
| _while | back to summary |
|---|---|
| public JWhileLoop _while(JExpression test) Create a While statement and add it to this block
| |
| add | back to summary |
|---|---|
| public JBlock add(JStatement s) Adds a statement to this block
| |
| assign | back to summary |
|---|---|
| public JBlock assign(JAssignmentTarget lhs, JExpression exp) Creates an assignment statement and adds it to this block.
| |
| assignPlus | back to summary |
|---|---|
| public JBlock assignPlus(JAssignmentTarget lhs, JExpression exp) | |
| block | back to summary |
|---|---|
| public JBlock block() Create a sub-block and add it to this block | |
| decl | back to summary |
|---|---|
| public JVar decl(JType type, String name) Adds a local variable declaration to this block | |
| decl | back to summary |
|---|---|
| public JVar decl(JType type, String name, JExpression init) Adds a local variable declaration to this block
| |
| decl | back to summary |
|---|---|
| public JVar decl(int mods, JType type, String name, JExpression init) Adds a local variable declaration to this block
| |
| directStatement | back to summary |
|---|---|
| public JStatement directStatement(final String source) Creates a "literal" statement directly. Specified string is printed as-is. This is useful as a short-cut.
For example, you can invoke this method as:
| |
| forEach | back to summary |
|---|---|
| public JForEach forEach(JType varType, String name, JExpression collection) Creates an enhanced For statement based on j2se 1.5 JLS and add it to this block
| |
| generate | back to summary |
|---|---|
| public void generate(JFormatter f) Implements com.
| |
| generateBody | back to summary |
|---|---|
| pack-priv void generateBody(JFormatter f) | |
| getContents | back to summary |
|---|---|
| public List Returns a read-only view of | |
| insert | back to summary |
|---|---|
| private <T> T insert(T statementOrDeclaration) | |
| invoke | back to summary |
|---|---|
| public JInvocation invoke(JExpression expr, String method) Creates an invocation statement and adds it to this block.
| |
| invoke | back to summary |
|---|---|
| public JInvocation invoke(JExpression expr, JMethod method) Creates an invocation statement and adds it to this block.
| |
| invoke | back to summary |
|---|---|
| public JInvocation invoke(String method) Creates an invocation statement and adds it to this block.
| |
| invoke | back to summary |
|---|---|
| public JInvocation invoke(JMethod method) Creates an invocation statement and adds it to this block.
| |
| isEmpty | back to summary |
|---|---|
| public boolean isEmpty() Returns true if this block is empty and does not contain any statement. | |
| label | back to summary |
|---|---|
| public JLabel label(String name) Create a label, which can be referenced from
| |
| pos | back to summary |
|---|---|
| public int pos() Gets the current position to which new statements will be inserted. For example if the value is 0, newly created instructions will be inserted at the very beginning of the block.
| |
| pos | back to summary |
|---|---|
| public int pos(int newPos) Sets the current position.
| |
| state | back to summary |
|---|---|
| public void state(JFormatter f) Implements com.
| |
| staticInvoke | back to summary |
|---|---|
| public JInvocation staticInvoke(JClass type, String method) Creates a static invocation statement. | |