本文整理匯總了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;
}