/** * Adds a statement to this block * * @param s * JStatement to be added * * @return This block */ public JBlock add(JStatement s) { // ## Needed? insert(s); return this; }
/** * Creates an invocation statement and adds it to this block. * * @param method * Name of method to invoke * * @return Newly generated JInvocation */ public JInvocation invoke(String method) { return insert(new JInvocation((JExpression)null, method)); }
/** * Create a For statement and add it to this block * * @return Newly generated For statement */ public JForLoop _for() { return insert(new JForLoop()); }
/** * Create a Try statement and add it to this block * * @return Newly generated Try statement */ public JTryBlock _try() { return insert(new JTryBlock()); }
/** * Create a continue statement and add it to this block */ public void _continue(JLabel label) { insert(new JContinue(label)); }
/** * Create an If statement and add it to this block * * @param expr * JExpression to be tested to determine branching * * @return Newly generated conditional statement */ public JConditional _if(JExpression expr) { return insert(new JConditional(expr)); }
/** * Create a switch/case statement and add it to this block */ public JSwitch _switch(JExpression test) { return insert(new JSwitch(test)); }
/** * Create a throw statement and add it to this block */ public void _throw(JExpression exp) { insert(new JThrow(exp)); }
/** * Creates a static invocation statement. */ public JInvocation staticInvoke(JClass type, String method) { return insert(new JInvocation(type, method)); }
/** * Creates an enhanced For statement based on j2se 1.5 JLS * and add it to this block * * @return Newly generated enhanced For statement per j2se 1.5 * specification */ public JForEach forEach(JType varType, String name, JExpression collection) { return insert(new JForEach( varType, name, collection)); } public void state(JFormatter f) {
/** * Create a sub-block and add it to this block */ public JBlock block() { JBlock b = new JBlock(); b.bracesRequired = false; b.indentRequired = false; return insert(b); }
/** * Create a While statement and add it to this block * * @return Newly generated While statement */ public JWhileLoop _while(JExpression test) { return insert(new JWhileLoop(test)); }
/** * Create a switch/case statement and add it to this block */ public JSwitch _switch(JExpression test) { return insert(new JSwitch(test)); }
/** * Create a Do statement and add it to this block * * @return Newly generated Do statement */ public JDoLoop _do(JExpression test) { return insert(new JDoLoop(test)); }
/** * Create a return statement and add it to this block */ public void _return(JExpression exp) { insert(new JReturn(exp)); }
/** * Creates a static invocation statement. */ public JInvocation staticInvoke(JClass type, String method) { return insert(new JInvocation(type, method)); }
/** * Create an If statement and add it to this block * * @param expr * JExpression to be tested to determine branching * * @return Newly generated conditional statement */ public JConditional _if(JExpression expr) { return insert(new JConditional(expr)); }
/** * Create a label, which can be referenced from * <code>continue</code> and <code>break</code> statements. */ public JLabel label(String name) { JLabel l = new JLabel(name); insert(l); return l; }
/** * Create a continue statement and add it to this block */ public void _continue(JLabel label) { insert(new JContinue(label)); }
/** * Create a Try statement and add it to this block * * @return Newly generated Try statement */ public JTryBlock _try() { return insert(new JTryBlock()); }