本文整理汇总了Java中com.sun.codemodel.JClass.array方法的典型用法代码示例。如果您正苦于以下问题:Java JClass.array方法的具体用法?Java JClass.array怎么用?Java JClass.array使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.codemodel.JClass
的用法示例。
在下文中一共展示了JClass.array方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: declareVectorValueSetupAndMember
import com.sun.codemodel.JClass; //导入方法依赖的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: buildClass
import com.sun.codemodel.JClass; //导入方法依赖的package包/类
private static JClass buildClass(JClassContainer _package, ClassOrInterfaceType c, int arrayCount) {
final String packagePrefix = (c.getScope() != null) ? c.getScope().toString() + "." : "";
JClass _class;
try {
_class = _package.owner().ref(Thread.currentThread().getContextClassLoader().loadClass(packagePrefix + c.getName()));
} catch (ClassNotFoundException e) {
_class = _package.owner().ref(packagePrefix + c.getName());
}
for (int i=0; i<arrayCount; i++) {
_class = _class.array();
}
List<Type> typeArgs = c.getTypeArgs();
if (typeArgs != null && typeArgs.size() > 0) {
JClass[] genericArgumentClasses = new JClass[typeArgs.size()];
for (int i=0; i<typeArgs.size(); i++) {
genericArgumentClasses[i] = buildClass(_package, (ClassOrInterfaceType) ((ReferenceType) typeArgs.get(i)).getType(), ((ReferenceType) typeArgs.get(i)).getArrayCount());
}
_class = _class.narrow(genericArgumentClasses);
}
return _class;
}
示例3: declareVectorValueSetupAndMember
import com.sun.codemodel.JClass; //导入方法依赖的package包/类
public JVar declareVectorValueSetupAndMember(DirectExpression batchName, TypedFieldId fieldId) {
final ValueVectorSetup setup = new ValueVectorSetup(batchName, fieldId);
// JVar var = this.vvDeclaration.get(setup);
// if(var != null) return var;
Class<?> valueVectorClass = fieldId.getIntermediateClass();
JClass vvClass = model.ref(valueVectorClass);
JClass retClass = vvClass;
String vectorAccess = "getValueVector";
if (fieldId.isHyperReader()) {
retClass = retClass.array();
vectorAccess = "getValueVectors";
}
JVar vv = declareClassField("vv", retClass);
JClass t = model.ref(SchemaChangeException.class);
JType objClass = model.ref(Object.class);
JBlock b = getSetupBlock();
//JExpr.newArray(model.INT).
JVar fieldArr = b.decl(model.INT.array(), "fieldIds" + index++, JExpr.newArray(model.INT, fieldId.getFieldIds().length));
int[] fieldIndices = fieldId.getFieldIds();
for (int i = 0; i < fieldIndices.length; i++) {
b.assign(fieldArr.component(JExpr.lit(i)), JExpr.lit(fieldIndices[i]));
}
JInvocation invoke = batchName
.invoke("getValueAccessorById") //
.arg( vvClass.dotclass())
.arg(fieldArr);
JVar obj = b.decl( //
objClass, //
getNextVar("tmp"), //
invoke.invoke(vectorAccess));
b._if(obj.eq(JExpr._null()))._then()._throw(JExpr._new(t).arg(JExpr.lit(String.format("Failure while loading vector %s with id: %s.", vv.name(), fieldId.toString()))));
//b.assign(vv, JExpr.cast(retClass, ((JExpression) JExpr.cast(wrapperClass, obj) ).invoke(vectorAccess)));
b.assign(vv, JExpr.cast(retClass, obj ));
vvDeclaration.put(setup, vv);
return vv;
}
示例4: declareVectorValueSetupAndMember
import com.sun.codemodel.JClass; //导入方法依赖的package包/类
/**
* Creates class variable for the value vector using metadata from {@code fieldId}
* and initializes it using setup blocks.
*
* @param batchName expression for invoking {@code getValueAccessorById} method
* @param fieldId metadata of the field that should be declared
* @return a newly generated class field
*/
public JVar declareVectorValueSetupAndMember(DirectExpression batchName, TypedFieldId fieldId) {
// declares field in the inner class if innerClassGenerator has been created
if (innerClassGenerator != null) {
return innerClassGenerator.declareVectorValueSetupAndMember(batchName, fieldId);
}
final ValueVectorSetup setup = new ValueVectorSetup(batchName, fieldId);
// JVar var = this.vvDeclaration.get(setup);
// if(var != null) return var;
Class<?> valueVectorClass = fieldId.getIntermediateClass();
JClass vvClass = model.ref(valueVectorClass);
JClass retClass = vvClass;
String vectorAccess = "getValueVector";
if (fieldId.isHyperReader()) {
retClass = retClass.array();
vectorAccess = "getValueVectors";
}
JVar vv = declareClassField("vv", retClass);
JClass t = model.ref(SchemaChangeException.class);
JType objClass = model.ref(Object.class);
JBlock b = getSetupBlock();
//JExpr.newArray(model.INT).
JVar fieldArr = b.decl(model.INT.array(), "fieldIds" + index++, JExpr.newArray(model.INT, fieldId.getFieldIds().length));
int[] fieldIndices = fieldId.getFieldIds();
for (int i = 0; i < fieldIndices.length; i++) {
b.assign(fieldArr.component(JExpr.lit(i)), JExpr.lit(fieldIndices[i]));
}
JInvocation invoke = batchName
.invoke("getValueAccessorById") //
.arg(vvClass.dotclass())
.arg(fieldArr);
JVar obj = b.decl(
objClass,
getNextVar("tmp"),
invoke.invoke(vectorAccess));
b._if(obj.eq(JExpr._null()))._then()._throw(JExpr._new(t).arg(JExpr.lit(String.format("Failure while loading vector %s with id: %s.", vv.name(), fieldId.toString()))));
//b.assign(vv, JExpr.cast(retClass, ((JExpression) JExpr.cast(wrapperClass, obj)).invoke(vectorAccess)));
b.assign(vv, JExpr.cast(retClass, obj));
vvDeclaration.put(setup, vv);
return vv;
}