简体   繁体   English

如何在Java中生成脚本代码?

[英]How to generate script code in java?

What is a good way to generate code from Java? 从Java生成代码的好方法是什么?

I have a visual FlowChart app, and want to integrate some code generation for specific graphs. 我有一个可视化的FlowChart应用程序,并希望为特定的图形集成一些代码生成。 So, I have mostly some objects (with names) and some connections between them (conditions). 因此,我主要拥有一些对象(带有名称)以及它们之间的一些连接(条件)。

I want these visual representation to transform in a specific type of scripting language. 我希望这些视觉表示形式可以转换为特定类型的脚本语言。

Is there anything in java so that I can somehow define a template to generate my script? Java中是否有任何东西,以便我可以以某种方式定义一个模板来生成我的脚本? Eg tell the template what properties to take from the visual objects, and how to arrange them in the output language? 例如,告诉模板从视觉对象获取什么属性,以及如何以输出语言排列它们?

尝试使用像FreeMarker这样的模板引擎,您可以生成任何您想要的东西。

You can try Apache Velocity : 您可以尝试Apache Velocity

The Apache Velocity Engine is a free open-source templating engine. Apache Velocity Engine是一个免费的开源模板引擎。

There is a comparison between FreeMarker and Velocity here . 有FreeMarker和速度之间的比较在这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM