class BasicJBlock extends BasicJCommentable implements JBlock, BlockContent
JBlock.Braces| Modifier and Type | Field and Description |
|---|---|
private JBlock.Braces |
braces |
private java.util.ArrayList<BlockContent> |
content |
private BasicJBlock |
parent |
private int |
tmpId |
| Constructor and Description |
|---|
BasicJBlock(BasicJBlock parent,
JBlock.Braces braces) |
| Modifier and Type | Method and Description |
|---|---|
JStatement |
_assert(JExpr expr)
Insert an
assert statement at this point. |
JStatement |
_assert(JExpr expr,
JExpr message)
Insert an
assert statement at this point with a message. |
JStatement |
_break()
Insert a
break statement at this point. |
JStatement |
_break(JLabel label)
Insert a labelled
break statement at this point. |
JClassDef |
_class(int mods,
java.lang.String name)
Insert a local class definition at this point.
|
JStatement |
_continue()
Insert a
continue statement at this point. |
JStatement |
_continue(JLabel label)
Insert a labelled
continue statement at this point. |
JBlock |
_do(JExpr cond)
Insert a
do/while statement at this point. |
JFor |
_for()
Insert a
for loop at this point. |
JIf |
_if(JExpr cond)
Insert an
if statement at this point. |
JCall |
_new(java.lang.Class<?> type)
Insert an object construction statement at this point.
|
JCall |
_new(JType type)
Insert an object construction statement at this point.
|
JCall |
_new(java.lang.String type)
Insert an object construction statement at this point.
|
JAnonymousClassDef |
_newAnon(java.lang.Class<?> type)
Insert an object construction statement for an anonymous class at this point.
|
JAnonymousClassDef |
_newAnon(JType type)
Insert an object construction statement for an anonymous class at this point.
|
JAnonymousClassDef |
_newAnon(java.lang.String type)
Insert an object construction statement for an anonymous class at this point.
|
JStatement |
_return()
Insert a
void return statement at this point. |
JStatement |
_return(JExpr expr)
Insert a
return statement at this point. |
JSwitch |
_switch(JExpr expr)
Insert a
switch statement at this point. |
JBlock |
_synchronized(JExpr synchExpr)
Insert a
synchronized block at this point. |
JStatement |
_throw(JExpr expr)
Insert a
throw statement at this point. |
JTry |
_try()
Insert a
try block at this point. |
JBlock |
_while(JExpr cond)
Insert a
while statement at this point. |
JStatement |
add(JExpr expr)
Insert an expression statement at this point.
|
private <T extends AbstractJCall> |
add(T item) |
private <T extends AbstractJExpr> |
add(T item) |
private <T extends BlockContent> |
add(T s) |
JStatement |
addAssign(JAssignableExpr target,
JExpr e1)
Insert an assignment (
+=) expression at this point. |
JStatement |
andAssign(JAssignableExpr target,
JExpr e1)
Insert an assignment (
&=) expression at this point. |
JLabel |
anonLabel()
Add a label at this point whose unique name is automatically generated.
|
JLabel |
anonLabel(JLabel label)
Name and attach a forward label as anonymous.
|
JStatement |
assign(JAssignableExpr target,
JExpr e1)
Insert an assignment (
=) expression at this point. |
JBlock |
blankLine()
Insert a blank line at this point.
|
JBlock |
block(JBlock.Braces braces)
Create a nested sub-block at this point.
|
JCall |
call(javax.lang.model.element.ExecutableElement element)
Insert a method invocation at this point.
|
JCall |
call(JExpr obj,
javax.lang.model.element.ExecutableElement element)
Insert a method invocation at this point.
|
JCall |
call(JExpr obj,
java.lang.String name)
Insert a method invocation at this point.
|
JCall |
call(java.lang.String name)
Insert a method invocation at this point.
|
JCall |
callStatic(java.lang.Class<?> type,
java.lang.String name)
Insert a type-qualified static method invocation at this point.
|
JCall |
callStatic(javax.lang.model.element.ExecutableElement element)
Insert a type-qualified static method invocation at this point.
|
JCall |
callStatic(JType type,
java.lang.String name)
Insert a type-qualified static method invocation at this point.
|
JCall |
callStatic(java.lang.String type,
java.lang.String name)
Insert a type-qualified static method invocation at this point.
|
JCall |
callSuper()
Insert a
super() call at this point. |
JCall |
callThis()
Insert a
this() call at this point. |
JStatement |
divAssign(JAssignableExpr target,
JExpr e1)
Insert an assignment (
/=) expression at this point. |
JStatement |
empty()
Insert an empty statement at this point (just a semicolon).
|
JBlock |
forEach(int mods,
java.lang.Class<?> type,
java.lang.String name,
JExpr iterable)
Insert a "for-each" style
for loop at this point. |
JBlock |
forEach(int mods,
JType type,
java.lang.String name,
JExpr iterable)
Insert a "for-each" style
for loop at this point. |
JBlock |
forEach(int mods,
java.lang.String type,
java.lang.String name,
JExpr iterable)
Insert a "for-each" style
for loop at this point. |
JLabel |
forwardLabel()
Create a forward label that can be named and attached later.
|
(package private) BlockContent |
get(int idx) |
(package private) BasicJBlock |
getParent() |
(package private) boolean |
hasSingleItemOfType(java.lang.Class<? extends BlockContent> type) |
JLabel |
label(JLabel label,
java.lang.String name)
Name and attach a forward label.
|
JLabel |
label(java.lang.String name)
Add a label at this point, which may be used for future branch instructions.
|
JStatement |
lshrAssign(JAssignableExpr target,
JExpr e1)
Insert an assignment (
>>>=) expression at this point. |
JStatement |
modAssign(JAssignableExpr target,
JExpr e1)
Insert an assignment (
%=) expression at this point. |
JStatement |
mulAssign(JAssignableExpr target,
JExpr e1)
Insert an assignment (
*=) expression at this point. |
JStatement |
orAssign(JAssignableExpr target,
JExpr e1)
Insert an assignment (
|=) expression at this point. |
JStatement |
postDec(JAssignableExpr target)
Insert a postfix
-- expression at this point. |
JStatement |
postInc(JAssignableExpr target)
Insert a postfix
++ expression at this point. |
JStatement |
preDec(JAssignableExpr target)
Insert a prefix
-- expression at this point. |
JStatement |
preInc(JAssignableExpr target)
Insert a prefix
++ expression at this point. |
JStatement |
shlAssign(JAssignableExpr target,
JExpr e1)
Insert an assignment (
<<=) expression at this point. |
JStatement |
shrAssign(JAssignableExpr target,
JExpr e1)
Insert an assignment (
>>=) expression at this point. |
(package private) int |
size() |
JStatement |
subAssign(JAssignableExpr target,
JExpr e1)
Insert an assignment (
-=) expression at this point. |
java.lang.String |
tempName()
Generate a temporary variable name.
|
JExpr |
tempVar(java.lang.Class<?> type,
JExpr value)
Insert a local variable declaration at this point with a generated name.
|
JExpr |
tempVar(JType type,
JExpr value)
Insert a local variable declaration at this point with a generated name.
|
JExpr |
tempVar(java.lang.String type,
JExpr value)
Insert a local variable declaration at this point with a generated name.
|
JVarDeclaration |
var(int mods,
java.lang.Class<?> type,
java.lang.String name)
Insert a local variable declaration at this point.
|
JVarDeclaration |
var(int mods,
java.lang.Class<?> type,
java.lang.String name,
JExpr value)
Insert a local variable declaration at this point.
|
JVarDeclaration |
var(int mods,
JType type,
java.lang.String name)
Insert a local variable declaration at this point.
|
JVarDeclaration |
var(int mods,
JType type,
java.lang.String name,
JExpr value)
Insert a local variable declaration at this point.
|
JVarDeclaration |
var(int mods,
java.lang.String type,
java.lang.String name)
Insert a local variable declaration at this point.
|
JVarDeclaration |
var(int mods,
java.lang.String type,
java.lang.String name,
JExpr value)
Insert a local variable declaration at this point.
|
void |
write(SourceFileWriter writer) |
(package private) void |
write(SourceFileWriter writer,
FormatPreferences.Space beforeBrace) |
(package private) void |
write(SourceFileWriter writer,
FormatPreferences.Space beforeBrace,
JBlock.Braces braces) |
JStatement |
xorAssign(JAssignableExpr target,
JExpr e1)
Insert an assignment (
^=) expression at this point. |
blockComment, lineComment, writeCommentsclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitblockComment, lineCommentprivate final BasicJBlock parent
private final java.util.ArrayList<BlockContent> content
private final JBlock.Braces braces
private int tmpId
BasicJBlock(BasicJBlock parent, JBlock.Braces braces)
private <T extends BlockContent> T add(T s)
private <T extends AbstractJExpr> ExpressionJStatement add(T item)
private <T extends AbstractJCall> T add(T item)
public JBlock blankLine()
JBlockpublic JBlock block(JBlock.Braces braces)
JBlockpublic JIf _if(JExpr cond)
JBlockif statement at this point.public JBlock _while(JExpr cond)
JBlockwhile statement at this point.public JBlock _do(JExpr cond)
JBlockdo/while statement at this point.public JLabel label(java.lang.String name)
JBlockpublic JLabel anonLabel()
JBlockpublic JLabel forwardLabel()
JBlockforwardLabel in interface JBlockpublic JLabel label(JLabel label, java.lang.String name)
JBlockpublic JLabel anonLabel(JLabel label)
JBlockpublic JStatement _continue()
JBlockcontinue statement at this point.public JStatement _continue(JLabel label)
JBlockcontinue statement at this point.public JStatement _break()
JBlockbreak statement at this point.public JStatement _break(JLabel label)
JBlockbreak statement at this point.public JBlock forEach(int mods, java.lang.String type, java.lang.String name, JExpr iterable)
JBlockfor loop at this point.public JBlock forEach(int mods, JType type, java.lang.String name, JExpr iterable)
JBlockfor loop at this point.public JBlock forEach(int mods, java.lang.Class<?> type, java.lang.String name, JExpr iterable)
JBlockfor loop at this point.public JSwitch _switch(JExpr expr)
JBlockswitch statement at this point.public JStatement _return(JExpr expr)
JBlockreturn statement at this point.public JStatement _return()
JBlockvoid return statement at this point.public JStatement _assert(JExpr expr)
JBlockassert statement at this point.public JStatement _assert(JExpr expr, JExpr message)
JBlockassert statement at this point with a message.public JCall callThis()
JBlockthis() call at this point.public JCall callSuper()
JBlocksuper() call at this point.public JStatement add(JExpr expr)
JBlockpublic JCall call(javax.lang.model.element.ExecutableElement element)
JBlock
block.call(element);
block.add(JExprs.call(element));
public JCall call(JExpr obj, javax.lang.model.element.ExecutableElement element)
JBlockpublic JCall call(java.lang.String name)
JBlock
block.call(methodName);
block.add(JExprs.call(methodName));
public JCall call(JExpr obj, java.lang.String name)
JBlockpublic JCall callStatic(javax.lang.model.element.ExecutableElement element)
JBlockcallStatic in interface JBlockelement - the program element whose name and type to usepublic JCall callStatic(java.lang.String type, java.lang.String name)
JBlockcallStatic in interface JBlocktype - the type upon which to invokename - the method namepublic JCall callStatic(JType type, java.lang.String name)
JBlockcallStatic in interface JBlocktype - the type upon which to invokename - the method namepublic JCall callStatic(java.lang.Class<?> type, java.lang.String name)
JBlockcallStatic in interface JBlocktype - the type upon which to invokename - the method namepublic JCall _new(java.lang.String type)
JBlockpublic JCall _new(JType type)
JBlockpublic JCall _new(java.lang.Class<?> type)
JBlockpublic JAnonymousClassDef _newAnon(java.lang.String type)
JBlockpublic JAnonymousClassDef _newAnon(JType type)
JBlockpublic JAnonymousClassDef _newAnon(java.lang.Class<?> type)
JBlockpublic JClassDef _class(int mods, java.lang.String name)
JBlockpublic JBlock _synchronized(JExpr synchExpr)
JBlocksynchronized block at this point._synchronized in interface JBlocksynchExpr - the lock expressionsynchronized blockpublic JStatement assign(JAssignableExpr target, JExpr e1)
JBlock=) expression at this point.public JStatement addAssign(JAssignableExpr target, JExpr e1)
JBlock+=) expression at this point.public JStatement subAssign(JAssignableExpr target, JExpr e1)
JBlock-=) expression at this point.public JStatement mulAssign(JAssignableExpr target, JExpr e1)
JBlock*=) expression at this point.public JStatement divAssign(JAssignableExpr target, JExpr e1)
JBlock/=) expression at this point.public JStatement modAssign(JAssignableExpr target, JExpr e1)
JBlock%=) expression at this point.public JStatement andAssign(JAssignableExpr target, JExpr e1)
JBlock&=) expression at this point.public JStatement orAssign(JAssignableExpr target, JExpr e1)
JBlock|=) expression at this point.public JStatement xorAssign(JAssignableExpr target, JExpr e1)
JBlock^=) expression at this point.public JStatement shrAssign(JAssignableExpr target, JExpr e1)
JBlock>>=) expression at this point.public JStatement lshrAssign(JAssignableExpr target, JExpr e1)
JBlock>>>=) expression at this point.lshrAssign in interface JBlocktarget - the assignment targete1 - the expression to applypublic JStatement shlAssign(JAssignableExpr target, JExpr e1)
JBlock<<=) expression at this point.public JStatement postInc(JAssignableExpr target)
JBlock++ expression at this point.public JStatement postDec(JAssignableExpr target)
JBlock-- expression at this point.public JStatement preInc(JAssignableExpr target)
JBlock++ expression at this point.public JStatement preDec(JAssignableExpr target)
JBlock-- expression at this point.public JStatement empty()
JBlockpublic JStatement _throw(JExpr expr)
JBlockthrow statement at this point.public JVarDeclaration var(int mods, java.lang.String type, java.lang.String name, JExpr value)
JBlockpublic JVarDeclaration var(int mods, JType type, java.lang.String name, JExpr value)
JBlockpublic JVarDeclaration var(int mods, java.lang.Class<?> type, java.lang.String name, JExpr value)
JBlockpublic JVarDeclaration var(int mods, java.lang.String type, java.lang.String name)
JBlockpublic JVarDeclaration var(int mods, JType type, java.lang.String name)
JBlockpublic JVarDeclaration var(int mods, java.lang.Class<?> type, java.lang.String name)
JBlockpublic JExpr tempVar(java.lang.String type, JExpr value)
JBlockpublic JExpr tempVar(JType type, JExpr value)
JBlockpublic JExpr tempVar(java.lang.Class<?> type, JExpr value)
JBlockpublic java.lang.String tempName()
JBlockBasicJBlock getParent()
int size()
BlockContent get(int idx)
void write(SourceFileWriter writer, FormatPreferences.Space beforeBrace) throws java.io.IOException
java.io.IOExceptionvoid write(SourceFileWriter writer, FormatPreferences.Space beforeBrace, JBlock.Braces braces) throws java.io.IOException
java.io.IOExceptionpublic void write(SourceFileWriter writer) throws java.io.IOException
boolean hasSingleItemOfType(java.lang.Class<? extends BlockContent> type)