private void generateSetup(ClassGenerator<?> g, JVar[] workspaceJVars) { JCodeModel m = g.getModel(); JBlock sub = new JBlock(true, true);
JBlock sub = new JBlock(true, true); if (inputVariables[i].isOptional()) { sub.assign(workspaceJVars[3].component(JExpr.lit(i)), workspaceJVars[2].component(JExpr.lit(i))); JBlock conditionalBlock = new JBlock(false, false); JConditional jc = conditionalBlock._if(inputVariables[i].getIsSet().ne(JExpr.lit(0))); jc._then().assign(JExpr.ref(workspaceJVars[3].component(JExpr.lit(i)), "valueHolder"), inputVariables[i].getHolder());
public static JBlock getDrillObject(JCodeModel m, ObjectInspector oi, JVar returnOI, JVar returnValueHolder, JVar returnValue) { JBlock block = new JBlock(false, false); switch(oi.getCategory()) { case PRIMITIVE: {
public static JBlock initReturnValueHolder(ClassGenerator<?> g, JCodeModel m, JVar returnValueHolder, ObjectInspector oi, MinorType returnType) { JBlock block = new JBlock(false, false); switch(oi.getCategory()) { case PRIMITIVE: {
/** * Creates, if necessary, and returns the static initializer * for this class. * * @return JBlock containing initialization statements for this class */ public JBlock init() { if (init == null) init = new JBlock(); return init; }
/** * Get the block that makes up body of this method * * @return Body of method */ public JBlock body() { if (body == null) body = new JBlock(); return body; }
/** * Create a block to be executed by "else" branch * * @return Newly generated else block */ public JBlock _else() { if (_else == null) _else = new JBlock(); return _else; }
public JBlock body() { if (body == null) body = new JBlock(); return body; }
/** * Create a block to be executed by "else" branch * * @return Newly generated else block */ public JBlock _else() { if (_else == null) _else = new JBlock(); return _else; }
/** * Creates, if necessary, and returns the static initializer * for this class. * * @return JBlock containing initialization statements for this class */ public JBlock init() { if (init == null) init = new JBlock(); return init; }
/** * Create a block to be executed by "else" branch * * @return Newly generated else block */ public JBlock _else() { if (_else == null) _else = new JBlock(); return _else; }
/** * Creates, if necessary, and returns the instance initializer * for this class. * * @return JBlock containing initialization statements for this class */ public JBlock instanceInit() { if (instanceInit == null) instanceInit = new JBlock(); return instanceInit; }
/** * Get the block that makes up body of this method * * @return Body of method */ public JBlock body() { if (body == null) body = new JBlock(); return body; }
/** * 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); }
public JBlock expectAnyElement() { if (expectValue) throw new IllegalArgumentException("A value is alredy expected"); if (expectAnyElement) throw new IllegalArgumentException("Any element is alredy expected"); expectAnyElement = true; JBlock block = new JBlock(); getParserBuilder().setAnyElementBlock(null, block); return block; }
public JBlock expectAnyElement() { if (expectValue) throw new IllegalArgumentException("A value is alredy expected"); if (expectAnyElement) throw new IllegalArgumentException("Any element is alredy expected"); expectAnyElement = true; JBlock block = new JBlock(); getParserBuilder().setAnyElementBlock(null, block); return block; }
private JBlock generateInitWorkspaceBlockHA(ClassGenerator<?> g, BlockType bt, String body, JVar[] workspaceJVars, JExpression wsIndexVariable){ JBlock initBlock = new JBlock(true, true); if(!Strings.isNullOrEmpty(body) && !body.trim().isEmpty()){ JBlock sub = new JBlock(true, true); addProtectedBlockHA(g, sub, body, null, workspaceJVars, wsIndexVariable); initBlock.directStatement(String.format("/** start %s for function %s **/ ", bt.name(), registeredNames[0])); initBlock.add(sub); initBlock.directStatement(String.format("/** end %s for function %s **/ ", bt.name(), registeredNames[0])); } return initBlock; }
/** * Creates an inner braced and indented block * @param type type of the created block * @return a newly created inner block */ private JBlock createInnerBlock(BlockType type) { final JBlock currBlock = getBlock(type); final JBlock innerBlock = new JBlock(); currBlock.add(innerBlock); return innerBlock; }
/** * Creates an inner braced and indented block * @param type type of the created block * @return a newly created inner block */ private JBlock createInnerBlock(BlockType type) { final JBlock currBlock = getBlock(type); final JBlock innerBlock = new JBlock(); currBlock.add(innerBlock); return innerBlock; }
@Override public JStatement buildFieldSet(boolean cast, ASTField field, TypedExpression expression, TypedExpression containingExpression) { JBlock assignmentBlock = new JBlock(false, false); assignmentBlock.assign(conditionalCast(cast, generationUtil.ref(containingExpression.getType()), containingExpression.getExpression()).ref(field.getName()), invocationHelper.coerceType(field.getASTType(), expression)); return assignmentBlock; }