本文整理匯總了Java中com.sun.codemodel.JCodeModel.ref方法的典型用法代碼示例。如果您正苦於以下問題:Java JCodeModel.ref方法的具體用法?Java JCodeModel.ref怎麽用?Java JCodeModel.ref使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.sun.codemodel.JCodeModel
的用法示例。
在下文中一共展示了JCodeModel.ref方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: loadParameterizedType
import com.sun.codemodel.JCodeModel; //導入方法依賴的package包/類
private JClass loadParameterizedType(JsonNode node, JCodeModel codeModel) {
String className = node.get("javaType").asText();
JClass ret = codeModel.ref(className);
if (node.has("javaTypeParams")) {
List<JClass> paramTypes = new ArrayList<JClass>();
JsonNode paramNode = node.get("javaTypeParams");
if (paramNode.isArray()) {
Iterator<JsonNode> it = paramNode.elements();
while (it.hasNext())
paramTypes.add(loadParameterizedType(it.next(), codeModel));
} else {
paramTypes.add(loadParameterizedType(paramNode, codeModel));
}
ret = ret.narrow(paramTypes);
}
return ret;
}
示例2: createRetrieveClass
import com.sun.codemodel.JCodeModel; //導入方法依賴的package包/類
private static void createRetrieveClass(Retrieve retrieve, String packageName, File destinationDir) throws JClassAlreadyExistsException, IOException {
JCodeModel codeModel = new JCodeModel();
JClass mapClass = codeModel.ref(String.format("%s.%sMap", packageName, retrieve.getId()));
JDefinedClass retrieveClass = codeModel._class(String.format("%s.%sRetrieve", packageName, retrieve.getId()));
retrieveClass.javadoc().append("Auto generated class. Do not modify!");
retrieveClass._extends(codeModel.ref(AbstractRetrieve.class).narrow(mapClass));
// Constructor
JMethod constructor = retrieveClass.constructor(JMod.PUBLIC);
constructor.param(String.class, "id");
constructor.body().invoke("super").arg(JExpr.ref("id"));
// Implemented method
JMethod getMapMethod = retrieveClass.method(JMod.PUBLIC, mapClass, "getMap");
getMapMethod.annotate(Override.class);
getMapMethod.param(codeModel.ref(Map.class).narrow(String.class, Object.class), "data");
getMapMethod.body()._return(JExpr._new(mapClass).arg(JExpr.ref("data")));
codeModel.build(destinationDir);
}
示例3: ref
import com.sun.codemodel.JCodeModel; //導入方法依賴的package包/類
public static JType ref(JCodeModel codeModel, String className) {
try {
// try the context class loader first
return codeModel.ref(Thread.currentThread().getContextClassLoader()
.loadClass(className));
} catch (ClassNotFoundException e) {
// fall through
}
// then the default mechanism.
try {
return codeModel.ref(Class.forName(className));
} catch (ClassNotFoundException e1) {
// fall through
}
{
JDefinedClass _class = _getClass(codeModel, className);
if (_class != null) {
return _class;
}
}
return codeModel.ref(className.replace('$', '.'));
}
示例4: visit
import com.sun.codemodel.JCodeModel; //導入方法依賴的package包/類
@Override
public JType visit(ClassOrInterfaceType type, JCodeModel codeModel) {
final String name = getName(type);
final JClass knownClass = this.knownClasses.get(name);
final JClass jclass = knownClass != null ? knownClass : codeModel
.ref(name);
final List<Type> typeArgs = type.getTypeArgs();
if (typeArgs == null || typeArgs.isEmpty()) {
return jclass;
} else {
final List<JClass> jtypeArgs = new ArrayList<JClass>(
typeArgs.size());
for (Type typeArg : typeArgs) {
final JType jtype = typeArg.accept(this, codeModel);
if (!(jtype instanceof JClass)) {
throw new IllegalArgumentException("Type argument ["
+ typeArg.toString() + "] is not a class.");
} else {
jtypeArgs.add((JClass) jtype);
}
}
return jclass.narrow(jtypeArgs);
}
}
示例5: getBasicTypes
import com.sun.codemodel.JCodeModel; //導入方法依賴的package包/類
public static JType[] getBasicTypes(final JCodeModel codeModel) {
final JType[] basicTypes = new JType[] { codeModel.BOOLEAN,
codeModel.BOOLEAN.boxify(), codeModel.BYTE,
codeModel.BYTE.boxify(), codeModel.CHAR,
codeModel.CHAR.boxify(), codeModel.DOUBLE,
codeModel.DOUBLE.boxify(), codeModel.FLOAT,
codeModel.FLOAT.boxify(), codeModel.INT,
codeModel.INT.boxify(), codeModel.LONG,
codeModel.LONG.boxify(), codeModel.SHORT,
codeModel.SHORT.boxify(), codeModel.ref(String.class),
codeModel.ref(BigInteger.class),
codeModel.ref(BigDecimal.class),
codeModel.ref(java.util.Date.class),
codeModel.ref(java.util.Calendar.class),
codeModel.ref(java.sql.Date.class),
codeModel.ref(java.sql.Time.class),
codeModel.ref(java.sql.Timestamp.class),
codeModel.BYTE.array(), codeModel.BYTE.boxify().array(),
codeModel.CHAR.array(), codeModel.CHAR.boxify().array() }
;
return basicTypes;
}
示例6: annotate
import com.sun.codemodel.JCodeModel; //導入方法依賴的package包/類
public void annotate(JCodeModel codeModel, JAnnotatable annotatable,
XAnnotation<?> xannotation) {
final JClass annotationClass = codeModel.ref(xannotation
.getAnnotationClass());
JAnnotationUse annotationUse = null;
for (JAnnotationUse annotation : annotatable.annotations()) {
if (annotationClass.equals(annotation.getAnnotationClass())) {
annotationUse = annotation;
}
}
if (annotationUse == null) {
annotationUse = annotatable.annotate(annotationClass);
}
final XAnnotationFieldVisitor<?> visitor = createAnnotationFieldVisitor(
codeModel, annotationUse);
for (XAnnotationField<?> field : xannotation.getFieldsList()) {
field.accept(visitor);
}
}
示例7: createReportingValueClass
import com.sun.codemodel.JCodeModel; //導入方法依賴的package包/類
private void createReportingValueClass(JCodeModel codeModel, String name, JPrimitiveType type) throws JClassAlreadyExistsException {
JClass reportClazz = codeModel.ref("org.jpmml.evaluator.Report");
JDefinedClass clazz = codeModel._class(JMod.PUBLIC, "org.jpmml.evaluator.Reporting" + name, ClassType.CLASS);
clazz._extends(codeModel.ref("org.jpmml.evaluator." + name));
clazz._implements(codeModel.ref("org.jpmml.evaluator.HasReport"));
JFieldVar reportField = clazz.field(JMod.PRIVATE, reportClazz, "report", JExpr._null());
createCopyMethod(clazz);
createOperationMethods(clazz, name, type);
createReportMethod(clazz);
createExpressionMethods(clazz);
createAccessorMethods(clazz, reportField);
createFormatMethod(clazz, type);
}
示例8: getIntegerType
import com.sun.codemodel.JCodeModel; //導入方法依賴的package包/類
private JType getIntegerType(JCodeModel owner, GenerationConfig config) {
if (config.isUseLongIntegers()) {
return owner.ref(Long.class);
} else {
return owner.ref(Integer.class);
}
}
示例9: getNumberType
import com.sun.codemodel.JCodeModel; //導入方法依賴的package包/類
private JType getNumberType(JCodeModel owner, GenerationConfig config) {
if (config.isUseDoubleNumbers()) {
return owner.ref(Double.class);
} else {
return owner.ref(Float.class);
}
}
示例10: getActorRef
import com.sun.codemodel.JCodeModel; //導入方法依賴的package包/類
private JExpression getActorRef(JCodeModel jm,
ConcreticisedMethod mth, String module, String method)
throws JClassAlreadyExistsException {
ConcurrentHashMap<String, String> newdef = mth.getProperties();
JClass actorT = jm.ref(module);
JInvocation newI = JExpr._new(jm.ref(module + ".Creator"));
JClass enm = jm.ref(module + ".MethodName");
newI.arg(JExpr._new(jm.ref(VisualProps.class)).arg(JExpr.invoke("getPath")).
arg(JExpr.lit(mth.supvisstrat.toString())).
arg(JExpr.lit(mth.maxnumofretr)).arg(JExpr.lit(mth.withTimeRange)));
newI.arg(enm.staticRef(method));
JArray args = JExpr.newArray(jm.ref(String.class));
for (String defValue
: newdef.values()) {
args.add(JExpr.lit(defValue));
}
newI.arg(args);
return jm.ref(Props.class
).staticInvoke("create").
arg(actorT.staticRef("class")).arg(newI);
}
示例11: getTemporalTypes
import com.sun.codemodel.JCodeModel; //導入方法依賴的package包/類
public static JType[] getTemporalTypes(final JCodeModel codeModel) {
final JType[] basicTypes = new JType[] {
codeModel.ref(java.util.Date.class),
codeModel.ref(java.util.Calendar.class),
codeModel.ref(java.sql.Date.class),
codeModel.ref(java.sql.Time.class),
codeModel.ref(java.sql.Timestamp.class) };
return basicTypes;
}
示例12: generate
import com.sun.codemodel.JCodeModel; //導入方法依賴的package包/類
public void generate(int mode, Dictionary props) throws Exception {
zclRootPackage = (String) props.get(OPT_ZCL_CLASSES_PACKAGE_NAME);
interfacesPackageName = (String) props.get(OPT_INTERFACES_PACKAGE_NAME);
outputPath = (String) props.get(OPT_OUTPUT_DIR);
clusters = (List) props.get(OPT_CLUSTER_NAME);
Boolean generateRecords = (Boolean) props.get("it.telecomitalia.ah.zigbee.zcl.generator.generateRecords");
Boolean generateProxyClasses = (Boolean) props.get(OPT_GENERATE_PROXY_CLASSES);
if (generateRecords != null) {
this.generateRecords = generateRecords.booleanValue();
}
if (generateProxyClasses != null) {
this.generateProxyClasses = generateProxyClasses.booleanValue();
}
if (this.zclClusters == null) {
throw new Exception("no parsed Cluster to generate. Call parse() first");
}
this.mode = mode;
jModel = new JCodeModel();
// commonly referenced classes
zbDeviceClass = jModel.ref(ZigBeeDevice.class);
jZclValidationException = jModel.ref(ZclValidationException.class);
jIZclAttributeDescription = jModel.ref(IZclAttributeDescriptor.class);
try {
buildCodeModel(zclClusters);
} catch (Throwable e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if (jModel != null) {
// generates the code of the previous cluster
dumpCodeModel(jModel);
}
}
示例13: JavaExprGen
import com.sun.codemodel.JCodeModel; //導入方法依賴的package包/類
JavaExprGen(JCodeModel model, JavaNameResolver context)
{
this.model = model;
this.context = context;
this.Type_t = model.ref(Type.class);
this.TypeInt_t = model.ref(TypeInt.class);
this.TypeFloat_t = model.ref(TypeFloat.class);
this.TypeString_t = model.ref(TypeString.class);
this.TypeList_t = model.ref(TypeList.class);
this.TypeMap_t = model.ref(TypeMap.class);
this.TypeBool_t = model.ref(TypeBool.class);
this.TypeBytes_t = model.ref(TypeBytes.class);
}
示例14: generateVisitMethod
import com.sun.codemodel.JCodeModel; //導入方法依賴的package包/類
private JMethod generateVisitMethod(final ClassOutline classOutline) {
final JDefinedClass definedClass = classOutline.implClass;
final JMethod visitMethod = definedClass.method(JMod.PUBLIC, definedClass, this.visitMethodName);
final JCodeModel codeModel = definedClass.owner();
final JClass visitorType = codeModel.ref(PropertyVisitor.class);
final JVar visitorParam = visitMethod.param(JMod.FINAL, visitorType, "_visitor_");
if (classOutline.getSuperClass() != null) {
visitMethod.body().add(JExpr._super().invoke(this.visitMethodName).arg(visitorParam));
} else {
visitMethod.body().add(visitorParam.invoke("visit").arg(JExpr._this()));
}
return visitMethod;
}
示例15: createTypeScaffold
import com.sun.codemodel.JCodeModel; //導入方法依賴的package包/類
private static Object createTypeScaffold(JCodeModel codeModel, JDefinedClass definedClass, FieldMeta field) {
if (field == null) {
return null;
}
Class<?> attrType = CodeBuilderHelper.stringToClass(field.getType());
if (field.getGenericType() == null) {
return (attrType != null) ? attrType : codeModel.ref(field.getType());
} else {
Class<?> genAttrType = CodeBuilderHelper.stringToClass(field.getGenericType());
JClass jfield = null;
if (genAttrType != null) {
if (attrType != null) {
jfield = codeModel.ref(attrType).narrow(genAttrType);
} else {
jfield = codeModel.ref(field.getType()).narrow(genAttrType);
}
} else {
if (attrType != null) {
jfield = codeModel.ref(attrType).narrow(codeModel.ref(field.getGenericType()));
} else {
jfield = codeModel.ref(field.getType()).narrow(codeModel.ref(field.getGenericType()));
}
}
return jfield;
}
}