有没有人知道如何自动从xml或json文件中生成Java源代码,在eclipse中进行?
我想做的一个很好的例子是Google Android sdk所做的:他们从resources自动生成了R类。
每次在Eclipse中保存资源文件时,都会自动重新生成R类。
更新:例子:
<tags>
<tag id="ALPHA">
<description>The first alpha tag.</description>
<value>231232</value>
</tag>
<tag id="BETA">
<description>This is the beta tag.</description>
<value>231232</value>
</tag>
然后在我生成的Java类中,比如R类,我会有类似以下的内容:
R.tags.ids.ALPHA //refers to an enum value for example
R.tags.values.ALPHA //refers to final int with avlue 231232
R.tags.descriptions.ALPHA //refers to the String with description
谢谢!