jcodemodel

How to initialise a 2D array using CodeModel

狂风中的少年 提交于 2019-12-20 06:02:32
问题 I need to initialise a 2d array like below Object[][] someName = { {"param1","param2","param3"}, {"param4","param5","param6"} }; I tried like JExpression exp = JExpr.newArray(codeModel.ref(String.class)).add(JExpr.lit("param1").add(JExpr.lit("param2")); methodBlock.decl(JMod.NONE, codeModel.ref(Object.class).array().array(), dataProviderName, exp); but it initilases 1d array, any help is appreciated 回答1: It might not be exactly the same, but the following code initializes the example 2d array

What is the role of ClassOutline / JClass / CClass in CodeModel?

*爱你&永不变心* 提交于 2019-12-17 06:13:29
问题 My question concerns writing JAXB plugins, in particular JAXB codemodel. What is the role of ClassOutline (and it's companions) and JClass (and companions) and CClass (and companions)? When looking at the list of classes in corresponding packages it is not clear what is chicken and what is egg. My interpretation is that CClass ( CPropertyInfo , CEnumConstant , ...) are created by XJC at first draft parsing of XSD. Then some magic happens and this model is transformed into JClass ( JFieldVar ,

How to initialise a 2D array using CodeModel

我是研究僧i 提交于 2019-12-02 11:41:15
I need to initialise a 2d array like below Object[][] someName = { {"param1","param2","param3"}, {"param4","param5","param6"} }; I tried like JExpression exp = JExpr.newArray(codeModel.ref(String.class)).add(JExpr.lit("param1").add(JExpr.lit("param2")); methodBlock.decl(JMod.NONE, codeModel.ref(Object.class).array().array(), dataProviderName, exp); but it initilases 1d array, any help is appreciated It might not be exactly the same, but the following code initializes the example 2d array: JDefinedClass testClass = codeModel._class("TestClass"); JMethod runme = testClass.method(JMod.PUBLIC,

What is the role of ClassOutline / JClass / CClass in CodeModel?

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-26 22:35:50
My question concerns writing JAXB plugins, in particular JAXB codemodel. What is the role of ClassOutline (and it's companions ) and JClass (and companions ) and CClass (and companions )? When looking at the list of classes in corresponding packages it is not clear what is chicken and what is egg. My interpretation is that CClass ( CPropertyInfo , CEnumConstant , ...) are created by XJC at first draft parsing of XSD. Then some magic happens and this model is transformed into JClass ( JFieldVar , JEnumConstant , ...) and during this transformation customizations are applied. Afterwards plugins