Package org.jboss.jdeparser
Interface JBlock
-
- All Superinterfaces:
JCommentable,JStatement
- All Known Implementing Classes:
BasicJBlock,CaseJBlock,ConditionJBlock,DefaultJBlock,DoJBlock,ElseJBlock,FinallyJBlock,ForEachJBlock,ForJBlock,ImplJCatch,ImplJIf,ImplJTry,InitJBlock,StaticInitJBlock,SynchJBlock,WhileJBlock
public interface JBlock extends JStatement, JCommentable
A block of code, to which statements may be added.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classJBlock.BracesBraces mode.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description JStatement_assert(JExpr expr)Insert anassertstatement at this point.JStatement_assert(JExpr expr, JExpr message)Insert anassertstatement at this point with a message.JStatement_break()Insert abreakstatement at this point.JStatement_break(JLabel label)Insert a labelledbreakstatement at this point.JClassDef_class(int mods, java.lang.String name)Insert a local class definition at this point.JStatement_continue()Insert acontinuestatement at this point.JStatement_continue(JLabel label)Insert a labelledcontinuestatement at this point.JBlock_do(JExpr cond)Insert ado/whilestatement at this point.JFor_for()Insert aforloop at this point.JIf_if(JExpr cond)Insert anifstatement at this point.JCall_new(java.lang.Class<?> type)Insert an object construction statement at this point.JCall_new(java.lang.String type)Insert an object construction statement at this point.JCall_new(JType 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(java.lang.String 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.JStatement_return()Insert avoidreturnstatement at this point.JStatement_return(JExpr expr)Insert areturnstatement at this point.JSwitch_switch(JExpr expr)Insert aswitchstatement at this point.JBlock_synchronized(JExpr synchExpr)Insert asynchronizedblock at this point.JStatement_throw(JExpr expr)Insert athrowstatement at this point.JTry_try()Insert atryblock at this point.JBlock_while(JExpr cond)Insert awhilestatement at this point.JStatementadd(JExpr expr)Insert an expression statement at this point.JStatementaddAssign(JAssignableExpr target, JExpr e1)Insert an assignment (+=) expression at this point.JStatementandAssign(JAssignableExpr target, JExpr e1)Insert an assignment (&=) expression at this point.JLabelanonLabel()Add a label at this point whose unique name is automatically generated.JLabelanonLabel(JLabel label)Name and attach a forward label as anonymous.JStatementassign(JAssignableExpr target, JExpr e1)Insert an assignment (=) expression at this point.JBlockblankLine()Insert a blank line at this point.JBlockblock(JBlock.Braces braces)Create a nested sub-block at this point.JCallcall(java.lang.String name)Insert a method invocation at this point.JCallcall(javax.lang.model.element.ExecutableElement element)Insert a method invocation at this point.JCallcall(JExpr obj, java.lang.String name)Insert a method invocation at this point.JCallcall(JExpr obj, javax.lang.model.element.ExecutableElement element)Insert a method invocation at this point.JCallcallStatic(java.lang.Class<?> type, java.lang.String name)Insert a type-qualified static method invocation at this point.JCallcallStatic(java.lang.String type, java.lang.String name)Insert a type-qualified static method invocation at this point.JCallcallStatic(javax.lang.model.element.ExecutableElement element)Insert a type-qualified static method invocation at this point.JCallcallStatic(JType type, java.lang.String name)Insert a type-qualified static method invocation at this point.JCallcallSuper()Insert asuper()call at this point.JCallcallThis()Insert athis()call at this point.JStatementdivAssign(JAssignableExpr target, JExpr e1)Insert an assignment (/=) expression at this point.JStatementempty()Insert an empty statement at this point (just a semicolon).JBlockforEach(int mods, java.lang.Class<?> type, java.lang.String name, JExpr iterable)Insert a "for-each" styleforloop at this point.JBlockforEach(int mods, java.lang.String type, java.lang.String name, JExpr iterable)Insert a "for-each" styleforloop at this point.JBlockforEach(int mods, JType type, java.lang.String name, JExpr iterable)Insert a "for-each" styleforloop at this point.JLabelforwardLabel()Create a forward label that can be named and attached later.JLabellabel(java.lang.String name)Add a label at this point, which may be used for future branch instructions.JLabellabel(JLabel label, java.lang.String name)Name and attach a forward label.JStatementlshrAssign(JAssignableExpr target, JExpr e1)Insert an assignment (>>>=) expression at this point.JStatementmodAssign(JAssignableExpr target, JExpr e1)Insert an assignment (%=) expression at this point.JStatementmulAssign(JAssignableExpr target, JExpr e1)Insert an assignment (*=) expression at this point.JStatementorAssign(JAssignableExpr target, JExpr e1)Insert an assignment (|=) expression at this point.JStatementpostDec(JAssignableExpr target)Insert a postfix--expression at this point.JStatementpostInc(JAssignableExpr target)Insert a postfix++expression at this point.JStatementpreDec(JAssignableExpr target)Insert a prefix--expression at this point.JStatementpreInc(JAssignableExpr target)Insert a prefix++expression at this point.JStatementshlAssign(JAssignableExpr target, JExpr e1)Insert an assignment (<<=) expression at this point.JStatementshrAssign(JAssignableExpr target, JExpr e1)Insert an assignment (>>=) expression at this point.JStatementsubAssign(JAssignableExpr target, JExpr e1)Insert an assignment (-=) expression at this point.java.lang.StringtempName()Generate a temporary variable name.JExprtempVar(java.lang.Class<?> type, JExpr value)Insert a local variable declaration at this point with a generated name.JExprtempVar(java.lang.String type, JExpr value)Insert a local variable declaration at this point with a generated name.JExprtempVar(JType type, JExpr value)Insert a local variable declaration at this point with a generated name.JVarDeclarationvar(int mods, java.lang.Class<?> type, java.lang.String name)Insert a local variable declaration at this point.JVarDeclarationvar(int mods, java.lang.Class<?> type, java.lang.String name, JExpr value)Insert a local variable declaration at this point.JVarDeclarationvar(int mods, java.lang.String type, java.lang.String name)Insert a local variable declaration at this point.JVarDeclarationvar(int mods, java.lang.String type, java.lang.String name, JExpr value)Insert a local variable declaration at this point.JVarDeclarationvar(int mods, JType type, java.lang.String name)Insert a local variable declaration at this point.JVarDeclarationvar(int mods, JType type, java.lang.String name, JExpr value)Insert a local variable declaration at this point.JStatementxorAssign(JAssignableExpr target, JExpr e1)Insert an assignment (^=) expression at this point.-
Methods inherited from interface org.jboss.jdeparser.JCommentable
blockComment, lineComment
-
-
-
-
Method Detail
-
blankLine
JBlock blankLine()
Insert a blank line at this point.- Returns:
- this block
-
block
JBlock block(JBlock.Braces braces)
Create a nested sub-block at this point.- Parameters:
braces- the rule for adding braces- Returns:
- the nested block
-
_if
JIf _if(JExpr cond)
Insert anifstatement at this point.- Parameters:
cond- theifcondition- Returns:
- the
ifstatement
-
_while
JBlock _while(JExpr cond)
Insert awhilestatement at this point.- Parameters:
cond- thewhilecondition- Returns:
- the
whilestatement
-
_do
JBlock _do(JExpr cond)
Insert ado/whilestatement at this point.- Parameters:
cond- thewhilecondition- Returns:
- the
whilestatement
-
label
JLabel label(java.lang.String name)
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
JLabel label(JLabel label, java.lang.String name)
Name and attach a forward label.- Parameters:
label- the label to name and attachname- the label name- Returns:
- the attached label
-
anonLabel
JLabel anonLabel(JLabel label)
Name and attach a forward label as anonymous.- Parameters:
label- the label to name and attach- Returns:
- the attached label
-
_continue
JStatement _continue()
Insert acontinuestatement at this point.- Returns:
- the statement
-
_continue
JStatement _continue(JLabel label)
Insert a labelledcontinuestatement at this point.- Parameters:
label- the label- Returns:
- the statement
-
_break
JStatement _break()
Insert abreakstatement at this point.- Returns:
- the statement
-
_break
JStatement _break(JLabel label)
Insert a labelledbreakstatement at this point.- Parameters:
label- the label- Returns:
- the statement
-
forEach
JBlock forEach(int mods, java.lang.String type, java.lang.String name, JExpr iterable)
Insert a "for-each" styleforloop 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
forloop
-
forEach
JBlock forEach(int mods, JType type, java.lang.String name, JExpr iterable)
Insert a "for-each" styleforloop 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
forloop
-
forEach
JBlock forEach(int mods, java.lang.Class<?> type, java.lang.String name, JExpr iterable)
Insert a "for-each" styleforloop 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
forloop
-
_for
JFor _for()
Insert aforloop at this point.- Returns:
- the
forloop
-
_switch
JSwitch _switch(JExpr expr)
Insert aswitchstatement at this point.- Parameters:
expr- theswitchexpression- Returns:
- the
switchstatement
-
_return
JStatement _return(JExpr expr)
Insert areturnstatement at this point.- Parameters:
expr- the expression to return- Returns:
- the statement
-
_return
JStatement _return()
Insert avoidreturnstatement at this point.- Returns:
- the statement
-
_assert
JStatement _assert(JExpr expr)
Insert anassertstatement at this point.- Parameters:
expr- the expression to assert- Returns:
- the statement
-
_assert
JStatement _assert(JExpr expr, JExpr message)
Insert anassertstatement 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
JStatement add(JExpr expr)
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
JCall call(javax.lang.model.element.ExecutableElement element)
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
JCall call(JExpr obj, javax.lang.model.element.ExecutableElement element)
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
JCall call(java.lang.String name)
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
JCall call(JExpr obj, java.lang.String name)
Insert a method invocation at this point.- Parameters:
obj- the expression upon which to invokename- the method name- Returns:
- the method call
-
callStatic
JCall callStatic(javax.lang.model.element.ExecutableElement element)
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
JCall callStatic(java.lang.String type, java.lang.String name)
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
JCall callStatic(JType type, java.lang.String name)
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
JCall callStatic(java.lang.Class<?> type, java.lang.String name)
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
JCall _new(java.lang.String type)
Insert an object construction statement at this point.- Parameters:
type- the type to instantiate- Returns:
- the constructor call
-
_new
JCall _new(JType type)
Insert an object construction statement at this point.- Parameters:
type- the type to instantiate- Returns:
- the constructor call
-
_new
JCall _new(java.lang.Class<?> type)
Insert an object construction statement at this point.- Parameters:
type- the type to instantiate- Returns:
- the constructor call
-
_newAnon
JAnonymousClassDef _newAnon(java.lang.String type)
Insert an object construction statement for an anonymous class at this point.- Parameters:
type- the type to instantiate- Returns:
- the anonymous class definition
-
_newAnon
JAnonymousClassDef _newAnon(JType type)
Insert an object construction statement for an anonymous class at this point.- Parameters:
type- the type to instantiate- Returns:
- the anonymous class definition
-
_newAnon
JAnonymousClassDef _newAnon(java.lang.Class<?> type)
Insert an object construction statement for an anonymous class at this point.- Parameters:
type- the type to instantiate- Returns:
- the anonymous class definition
-
_class
JClassDef _class(int mods, java.lang.String name)
Insert a local class definition at this point.- Parameters:
mods- the class modifiersname- the local class name- Returns:
- the local class definition
-
_synchronized
JBlock _synchronized(JExpr synchExpr)
Insert asynchronizedblock at this point.- Parameters:
synchExpr- the lock expression- Returns:
- the
synchronizedblock
-
assign
JStatement assign(JAssignableExpr target, JExpr e1)
Insert an assignment (=) expression at this point.- Parameters:
target- the assignment targete1- the expression to apply- Returns:
- the statement
-
addAssign
JStatement addAssign(JAssignableExpr target, JExpr e1)
Insert an assignment (+=) expression at this point.- Parameters:
target- the assignment targete1- the expression to apply- Returns:
- the statement
-
subAssign
JStatement subAssign(JAssignableExpr target, JExpr e1)
Insert an assignment (-=) expression at this point.- Parameters:
target- the assignment targete1- the expression to apply- Returns:
- the statement
-
mulAssign
JStatement mulAssign(JAssignableExpr target, JExpr e1)
Insert an assignment (*=) expression at this point.- Parameters:
target- the assignment targete1- the expression to apply- Returns:
- the statement
-
divAssign
JStatement divAssign(JAssignableExpr target, JExpr e1)
Insert an assignment (/=) expression at this point.- Parameters:
target- the assignment targete1- the expression to apply- Returns:
- the statement
-
modAssign
JStatement modAssign(JAssignableExpr target, JExpr e1)
Insert an assignment (%=) expression at this point.- Parameters:
target- the assignment targete1- the expression to apply- Returns:
- the statement
-
andAssign
JStatement andAssign(JAssignableExpr target, JExpr e1)
Insert an assignment (&=) expression at this point.- Parameters:
target- the assignment targete1- the expression to apply- Returns:
- the statement
-
orAssign
JStatement orAssign(JAssignableExpr target, JExpr e1)
Insert an assignment (|=) expression at this point.- Parameters:
target- the assignment targete1- the expression to apply- Returns:
- the statement
-
xorAssign
JStatement xorAssign(JAssignableExpr target, JExpr e1)
Insert an assignment (^=) expression at this point.- Parameters:
target- the assignment targete1- the expression to apply- Returns:
- the statement
-
shrAssign
JStatement shrAssign(JAssignableExpr target, JExpr e1)
Insert an assignment (>>=) expression at this point.- Parameters:
target- the assignment targete1- the expression to apply- Returns:
- the statement
-
lshrAssign
JStatement lshrAssign(JAssignableExpr target, JExpr e1)
Insert an assignment (>>>=) expression at this point.- Parameters:
target- the assignment targete1- the expression to apply- Returns:
- the statement
-
shlAssign
JStatement shlAssign(JAssignableExpr target, JExpr e1)
Insert an assignment (<<=) expression at this point.- Parameters:
target- the assignment targete1- the expression to apply- Returns:
- the statement
-
postInc
JStatement postInc(JAssignableExpr target)
Insert a postfix++expression at this point.- Parameters:
target- the target expression- Returns:
- the statement
-
postDec
JStatement postDec(JAssignableExpr target)
Insert a postfix--expression at this point.- Parameters:
target- the target expression- Returns:
- the statement
-
preInc
JStatement preInc(JAssignableExpr target)
Insert a prefix++expression at this point.- Parameters:
target- the target expression- Returns:
- the statement
-
preDec
JStatement preDec(JAssignableExpr target)
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
JStatement _throw(JExpr expr)
Insert athrowstatement at this point.- Parameters:
expr- the expression to throw- Returns:
- the statement
-
_try
JTry _try()
Insert atryblock at this point.- Returns:
- the
tryblock
-
var
JVarDeclaration var(int mods, java.lang.String type, java.lang.String name, JExpr value)
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
JVarDeclaration var(int mods, JType type, java.lang.String name, JExpr value)
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
JVarDeclaration var(int mods, java.lang.Class<?> type, java.lang.String name, JExpr value)
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
JVarDeclaration var(int mods, java.lang.String type, java.lang.String name)
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
JVarDeclaration var(int mods, JType type, java.lang.String name)
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
JVarDeclaration var(int mods, java.lang.Class<?> type, java.lang.String name)
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
JExpr tempVar(java.lang.String type, JExpr value)
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
JExpr tempVar(JType type, JExpr value)
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
JExpr tempVar(java.lang.Class<?> type, JExpr value)
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
java.lang.String tempName()
Generate a temporary variable name.- Returns:
- the generated name
-
-