Package org.jboss.jdeparser
Interface JBlock
- All Superinterfaces:
JCommentable
,JStatement
A block of code, to which statements may be added.
- Author:
- David M. Lloyd
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionInsert anassert
statement at this point.Insert anassert
statement at this point with a message._break()
Insert abreak
statement at this point.Insert a labelledbreak
statement at this point.Insert a local class definition at this point.Insert acontinue
statement at this point.Insert a labelledcontinue
statement at this point.Insert ado
/while
statement at this point._for()
Insert afor
loop at this point.Insert anif
statement at this point.Insert an object construction statement at this point.Insert an object construction statement at this point.Insert an object construction statement at this point.Insert an object construction statement for an anonymous class at this point.Insert an object construction statement for an anonymous class at this point.Insert an object construction statement for an anonymous class at this point._return()
Insert avoid
return
statement at this point.Insert areturn
statement at this point.Insert aswitch
statement at this point._synchronized
(JExpr synchExpr) Insert asynchronized
block at this point.Insert athrow
statement at this point._try()
Insert atry
block at this point.Insert awhile
statement at this point.Insert an expression statement at this point.addAssign
(JAssignableExpr target, JExpr e1) Insert an assignment (+=
) expression at this point.andAssign
(JAssignableExpr target, JExpr e1) Insert an assignment (&=
) expression at this point.Add a label at this point whose unique name is automatically generated.Name and attach a forward label as anonymous.assign
(JAssignableExpr target, JExpr e1) Insert an assignment (=
) expression at this point.Insert a blank line at this point.block
(JBlock.Braces braces) Create a nested sub-block at this point.Insert a method invocation at this point.call
(ExecutableElement element) Insert a method invocation at this point.Insert a method invocation at this point.call
(JExpr obj, ExecutableElement element) Insert a method invocation at this point.callStatic
(Class<?> type, String name) Insert a type-qualified static method invocation at this point.callStatic
(String type, String name) Insert a type-qualified static method invocation at this point.callStatic
(ExecutableElement element) Insert a type-qualified static method invocation at this point.callStatic
(JType type, String name) Insert a type-qualified static method invocation at this point.Insert asuper()
call at this point.callThis()
Insert athis()
call at this point.divAssign
(JAssignableExpr target, JExpr e1) Insert an assignment (/=
) expression at this point.empty()
Insert an empty statement at this point (just a semicolon).Insert a "for-each" stylefor
loop at this point.Insert a "for-each" stylefor
loop at this point.Insert a "for-each" stylefor
loop at this point.Create a forward label that can be named and attached later.Add a label at this point, which may be used for future branch instructions.Name and attach a forward label.lshrAssign
(JAssignableExpr target, JExpr e1) Insert an assignment (>>>=
) expression at this point.modAssign
(JAssignableExpr target, JExpr e1) Insert an assignment (%=
) expression at this point.mulAssign
(JAssignableExpr target, JExpr e1) Insert an assignment (*=
) expression at this point.orAssign
(JAssignableExpr target, JExpr e1) Insert an assignment (|=
) expression at this point.postDec
(JAssignableExpr target) Insert a postfix--
expression at this point.postInc
(JAssignableExpr target) Insert a postfix++
expression at this point.preDec
(JAssignableExpr target) Insert a prefix--
expression at this point.preInc
(JAssignableExpr target) Insert a prefix++
expression at this point.shlAssign
(JAssignableExpr target, JExpr e1) Insert an assignment (<<=
) expression at this point.shrAssign
(JAssignableExpr target, JExpr e1) Insert an assignment (>>=
) expression at this point.subAssign
(JAssignableExpr target, JExpr e1) Insert an assignment (-=
) expression at this point.tempName()
Generate a temporary variable name.Insert a local variable declaration at this point with a generated name.Insert a local variable declaration at this point with a generated name.Insert a local variable declaration at this point with a generated name.Insert a local variable declaration at this point.Insert a local variable declaration at this point.Insert a local variable declaration at this point.Insert a local variable declaration at this point.Insert a local variable declaration at this point.Insert a local variable declaration at this point.xorAssign
(JAssignableExpr target, JExpr e1) Insert an assignment (^=
) expression at this point.Methods inherited from interface org.jboss.jdeparser.JCommentable
blockComment, lineComment
-
Method Details
-
blankLine
JBlock blankLine()Insert a blank line at this point.- Returns:
- this block
-
block
Create a nested sub-block at this point.- Parameters:
braces
- the rule for adding braces- Returns:
- the nested block
-
_if
Insert anif
statement at this point.- Parameters:
cond
- theif
condition- Returns:
- the
if
statement
-
_while
Insert awhile
statement at this point.- Parameters:
cond
- thewhile
condition- Returns:
- the
while
statement
-
_do
Insert ado
/while
statement at this point.- Parameters:
cond
- thewhile
condition- Returns:
- the
while
statement
-
label
Add a label at this point, which may be used for future branch instructions.- Parameters:
name
- the label name- Returns:
- the label
-
anonLabel
JLabel anonLabel()Add a label at this point whose unique name is automatically generated.- Returns:
- the label
-
forwardLabel
JLabel forwardLabel()Create a forward label that can be named and attached later.- Returns:
- the forward label
-
label
Name and attach a forward label.- Parameters:
label
- the label to name and attachname
- the label name- Returns:
- the attached label
-
anonLabel
Name and attach a forward label as anonymous.- Parameters:
label
- the label to name and attach- Returns:
- the attached label
-
_continue
JStatement _continue()Insert acontinue
statement at this point.- Returns:
- the statement
-
_continue
Insert a labelledcontinue
statement at this point.- Parameters:
label
- the label- Returns:
- the statement
-
_break
JStatement _break()Insert abreak
statement at this point.- Returns:
- the statement
-
_break
Insert a labelledbreak
statement at this point.- Parameters:
label
- the label- Returns:
- the statement
-
forEach
Insert a "for-each" stylefor
loop at this point.- Parameters:
mods
- the item variable modifierstype
- the item variable typename
- the item variable nameiterable
- the iterable or array expression- Returns:
- the body of the
for
loop
-
forEach
Insert a "for-each" stylefor
loop at this point.- Parameters:
mods
- the item variable modifierstype
- the item variable typename
- the item variable nameiterable
- the iterable or array expression- Returns:
- the body of the
for
loop
-
forEach
Insert a "for-each" stylefor
loop at this point.- Parameters:
mods
- the item variable modifierstype
- the item variable typename
- the item variable nameiterable
- the iterable or array expression- Returns:
- the body of the
for
loop
-
_for
JFor _for()Insert afor
loop at this point.- Returns:
- the
for
loop
-
_switch
Insert aswitch
statement at this point.- Parameters:
expr
- theswitch
expression- Returns:
- the
switch
statement
-
_return
Insert areturn
statement at this point.- Parameters:
expr
- the expression to return- Returns:
- the statement
-
_return
JStatement _return()Insert avoid
return
statement at this point.- Returns:
- the statement
-
_assert
Insert anassert
statement at this point.- Parameters:
expr
- the expression to assert- Returns:
- the statement
-
_assert
Insert anassert
statement at this point with a message.- Parameters:
expr
- the expression to assertmessage
- the assertion message- Returns:
- the statement
-
callThis
JCall callThis()Insert athis()
call at this point.- Returns:
- the call
-
callSuper
JCall callSuper()Insert asuper()
call at this point.- Returns:
- the call
-
add
Insert an expression statement at this point. Expressions which are invalid statements may generate an error at the time this method is called, or at compile time.- Parameters:
expr
- the expression to add- Returns:
- the statement
-
call
Insert a method invocation at this point. Note that these two invocations are identical:block.call(element); block.add(JExprs.call(element));
- Parameters:
element
- the program element whose name to use- Returns:
- the method call
-
call
Insert a method invocation at this point.- Parameters:
obj
- the expression upon which to invokeelement
- the program element whose name to use- Returns:
- the method call
-
call
Insert a method invocation at this point. Note that these two invocations are identical:block.call(methodName); block.add(JExprs.call(methodName));
- Parameters:
name
- the method name- Returns:
- the method call
-
call
Insert a method invocation at this point.- Parameters:
obj
- the expression upon which to invokename
- the method name- Returns:
- the method call
-
callStatic
Insert a type-qualified static method invocation at this point.- Parameters:
element
- the program element whose name and type to use- Returns:
- the method call
-
callStatic
Insert a type-qualified static method invocation at this point.- Parameters:
type
- the type upon which to invokename
- the method name- Returns:
- the method call
-
callStatic
Insert a type-qualified static method invocation at this point.- Parameters:
type
- the type upon which to invokename
- the method name- Returns:
- the method call
-
callStatic
Insert a type-qualified static method invocation at this point.- Parameters:
type
- the type upon which to invokename
- the method name- Returns:
- the method call
-
_new
Insert an object construction statement at this point.- Parameters:
type
- the type to instantiate- Returns:
- the constructor call
-
_new
Insert an object construction statement at this point.- Parameters:
type
- the type to instantiate- Returns:
- the constructor call
-
_new
Insert an object construction statement at this point.- Parameters:
type
- the type to instantiate- Returns:
- the constructor call
-
_newAnon
Insert an object construction statement for an anonymous class at this point.- Parameters:
type
- the type to instantiate- Returns:
- the anonymous class definition
-
_newAnon
Insert an object construction statement for an anonymous class at this point.- Parameters:
type
- the type to instantiate- Returns:
- the anonymous class definition
-
_newAnon
Insert an object construction statement for an anonymous class at this point.- Parameters:
type
- the type to instantiate- Returns:
- the anonymous class definition
-
_class
Insert a local class definition at this point.- Parameters:
mods
- the class modifiersname
- the local class name- Returns:
- the local class definition
-
_synchronized
Insert asynchronized
block at this point.- Parameters:
synchExpr
- the lock expression- Returns:
- the
synchronized
block
-
assign
Insert an assignment (=
) expression at this point.- Parameters:
target
- the assignment targete1
- the expression to apply- Returns:
- the statement
-
addAssign
Insert an assignment (+=
) expression at this point.- Parameters:
target
- the assignment targete1
- the expression to apply- Returns:
- the statement
-
subAssign
Insert an assignment (-=
) expression at this point.- Parameters:
target
- the assignment targete1
- the expression to apply- Returns:
- the statement
-
mulAssign
Insert an assignment (*=
) expression at this point.- Parameters:
target
- the assignment targete1
- the expression to apply- Returns:
- the statement
-
divAssign
Insert an assignment (/=
) expression at this point.- Parameters:
target
- the assignment targete1
- the expression to apply- Returns:
- the statement
-
modAssign
Insert an assignment (%=
) expression at this point.- Parameters:
target
- the assignment targete1
- the expression to apply- Returns:
- the statement
-
andAssign
Insert an assignment (&=
) expression at this point.- Parameters:
target
- the assignment targete1
- the expression to apply- Returns:
- the statement
-
orAssign
Insert an assignment (|=
) expression at this point.- Parameters:
target
- the assignment targete1
- the expression to apply- Returns:
- the statement
-
xorAssign
Insert an assignment (^=
) expression at this point.- Parameters:
target
- the assignment targete1
- the expression to apply- Returns:
- the statement
-
shrAssign
Insert an assignment (>>=
) expression at this point.- Parameters:
target
- the assignment targete1
- the expression to apply- Returns:
- the statement
-
lshrAssign
Insert an assignment (>>>=
) expression at this point.- Parameters:
target
- the assignment targete1
- the expression to apply- Returns:
- the statement
-
shlAssign
Insert an assignment (<<=
) expression at this point.- Parameters:
target
- the assignment targete1
- the expression to apply- Returns:
- the statement
-
postInc
Insert a postfix++
expression at this point.- Parameters:
target
- the target expression- Returns:
- the statement
-
postDec
Insert a postfix--
expression at this point.- Parameters:
target
- the target expression- Returns:
- the statement
-
preInc
Insert a prefix++
expression at this point.- Parameters:
target
- the target expression- Returns:
- the statement
-
preDec
Insert a prefix--
expression at this point.- Parameters:
target
- the target expression- Returns:
- the statement
-
empty
JStatement empty()Insert an empty statement at this point (just a semicolon).- Returns:
- the statement
-
_throw
Insert athrow
statement at this point.- Parameters:
expr
- the expression to throw- Returns:
- the statement
-
_try
JTry _try()Insert atry
block at this point.- Returns:
- the
try
block
-
var
Insert a local variable declaration at this point.- Parameters:
mods
- the variable modifierstype
- the local variable typename
- the local variable namevalue
- the local variable's initializer expression- Returns:
- the local variable declaration
-
var
Insert a local variable declaration at this point.- Parameters:
mods
- the variable modifierstype
- the local variable typename
- the local variable namevalue
- the local variable's initializer expression- Returns:
- the local variable declaration
-
var
Insert a local variable declaration at this point.- Parameters:
mods
- the variable modifierstype
- the local variable typename
- the local variable namevalue
- the local variable's initializer expression- Returns:
- the local variable declaration
-
var
Insert a local variable declaration at this point.- Parameters:
mods
- the variable modifierstype
- the local variable typename
- the local variable name- Returns:
- the local variable declaration
-
var
Insert a local variable declaration at this point.- Parameters:
mods
- the variable modifierstype
- the local variable typename
- the local variable name- Returns:
- the local variable declaration
-
var
Insert a local variable declaration at this point.- Parameters:
mods
- the variable modifierstype
- the local variable typename
- the local variable name- Returns:
- the local variable declaration
-
tempVar
Insert a local variable declaration at this point with a generated name.- Parameters:
type
- the local variable typevalue
- the local variable's initializer expression- Returns:
- the local variable expression
-
tempVar
Insert a local variable declaration at this point with a generated name.- Parameters:
type
- the local variable typevalue
- the local variable's initializer expression- Returns:
- the local variable expression
-
tempVar
Insert a local variable declaration at this point with a generated name.- Parameters:
type
- the local variable typevalue
- the local variable's initializer expression- Returns:
- the local variable expression
-
tempName
String tempName()Generate a temporary variable name.- Returns:
- the generated name
-