本文整理汇总了Java中com.sun.codemodel.JExpr.cast方法的典型用法代码示例。如果您正苦于以下问题:Java JExpr.cast方法的具体用法?Java JExpr.cast怎么用?Java JExpr.cast使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.codemodel.JExpr
的用法示例。
在下文中一共展示了JExpr.cast方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: declareVectorValueSetupAndMember
import com.sun.codemodel.JExpr; //导入方法依赖的package包/类
public JVar declareVectorValueSetupAndMember(DirectExpression batchName, TypedFieldId fieldId) {
final ValueVectorSetup setup = new ValueVectorSetup(batchName, fieldId);
final Class<?> valueVectorClass = fieldId.getIntermediateClass();
final JClass vvClass = model.ref(valueVectorClass);
final JClass retClass = fieldId.isHyperReader() ? vvClass.array() : vvClass;
final JVar vv = declareClassField("vv", retClass);
final JBlock b = getSetupBlock();
int[] fieldIndices = fieldId.getFieldIds();
JInvocation invoke = model.ref(VectorResolver.class).staticInvoke(fieldId.isHyperReader() ? "hyper" : "simple")
.arg(batchName)
.arg(vvClass.dotclass());
for(int i = 0; i < fieldIndices.length; i++){
invoke.arg(JExpr.lit(fieldIndices[i]));
}
// we have to cast here since Janino doesn't handle generic inference well.
JExpression casted = JExpr.cast(retClass, invoke);
b.assign(vv, casted);
vvDeclaration.put(setup, vv);
return vv;
}
示例2: generateEvalBody
import com.sun.codemodel.JExpr; //导入方法依赖的package包/类
@Override
protected HoldingContainer generateEvalBody(ClassGenerator<?> g, HoldingContainer[] inputVariables, String body, JVar[] workspaceJVars) {
g.getEvalBlock().directStatement(String.format("//---- start of eval portion of %s function. ----//", registeredNames[0]));
JBlock sub = new JBlock(true, true);
JBlock topSub = sub;
JVar complexWriter = g.declareClassField("complexWriter", g.getModel()._ref(ComplexWriter.class));
JClass cwClass = g.getModel().ref(ComplexWriterImpl.class);
JInvocation container = g.getMappingSet().getOutgoing().invoke("getOutgoingContainer");
//Default name is "col", if not passed in a reference name for the output vector.
String refName = ref == null? "col" : ref.getRootSegment().getPath();
g.getSetupBlock().assign(complexWriter, cwClass.staticInvoke("getWriter").arg(refName).arg(container));
JClass projBatchClass = g.getModel().ref(ProjectRecordBatch.class);
JExpression projBatch = JExpr.cast(projBatchClass, g.getMappingSet().getOutgoing());
g.getSetupBlock().add(projBatch.invoke("addComplexWriter").arg(complexWriter));
g.getEvalBlock().add(complexWriter.invoke("setPosition").arg(g.getMappingSet().getValueWriteIndex()));
sub.decl(g.getModel()._ref(ComplexWriter.class), returnValue.name, complexWriter);
// add the subblock after the out declaration.
g.getEvalBlock().add(topSub);
addProtectedBlock(g, sub, body, inputVariables, workspaceJVars, false);
// JConditional jc = g.getEvalBlock()._if(complexWriter.invoke("ok").not());
// jc._then().add(complexWriter.invoke("reset"));
//jc._then().directStatement("System.out.println(\"debug : write ok fail!, inIndex = \" + inIndex);");
// jc._then()._return(JExpr.FALSE);
//jc._else().directStatement("System.out.println(\"debug : write successful, inIndex = \" + inIndex);");
g.getEvalBlock().directStatement(String.format("//---- end of eval portion of %s function. ----//", registeredNames[0]));
return null;
}