xml生成java_在Eclipse中从XML生成Java代码
小编典典这正是模型到文本(M2T)项目中的JET组件的用途。实际上,您甚至可以使用JET创建项目,.classpath以及所需的任何其他文件。Jet模板如下。请注意,这些模板必须完全按照所示命名。/templates/main.jetLet c:iterate tags set the XPath context object.For 100% compatibility with JET 0.9
小编典典
这正是模型到文本(M2T)项目中的JET组件的用途。实际上,您甚至可以使用JET创建项目,.classpath以及所需的任何其他文件。
Jet模板如下。请注意,这些模板必须完全按照所示命名。
/templates/main.jet
Let c:iterate tags set the XPath context object.
For 100% compatibility with JET 0.9.x or earlier, remove this statement
--%>
--- traverse input model, performing calculations and storing
--- the results as model annotations via c:set tag
com.lacqui.commands
com.lacqui.commands
- Derive the class name from the name of the command
Command
false
--- traverse annotated model, performing text generation actions
--- such as ws:file, ws:folder and ws:project
/templates/classpath.jet
/templates/project.jet
org.eclipse.jdt.core.javabuilder
org.eclipse.jdt.core.javanature
/templates/class.jet
package ;
public class extends Command {
public ResponseCode execute() {
Server srv = getServer();
if (srv.hasCapability(Capabilities.) == false) {
Log.debug("Attempting non-available capability: ");
}
String = getArgument("");
if ( == null) {
throw new InvalidArgumentException("Require ");
}
String command = "GROUP";
if ( != null) command += " - " + ;
srv.send(command);
return srv.getResponse();
}
}
并使用此模型:
提供了一个完整的Java项目com.lacqui.commands,其中包含三个Java文件:
package com.lacqui.commands;
public class ArticleCommand extends Command {
public ResponseCode execute() {
Server srv = getServer();
if (srv.hasCapability(Capabilities.READER) == false) {
Log.debug("Attempting non-available capability: READER");
}
String article-id = getArgument("article-id");
if (article-id == null) {
throw new InvalidArgumentException("Require article-id");
}
String message-id = getArgument("message-id");
String command = "GROUP";
if (article-id != null) command += " -article-id " + article-id;
if (message-id != null) command += " -message-id " + message-id;
srv.send(command);
return srv.getResponse();
}
}
还有这个:
package com.lacqui.commands;
public class GroupCommand extends Command {
public ResponseCode execute() {
Server srv = getServer();
if (srv.hasCapability(Capabilities.LOGGER) == false) {
Log.debug("Attempting non-available capability: LOGGER");
}
if (srv.hasCapability(Capabilities.AUTHENTICATOR) == false) {
Log.debug("Attempting non-available capability: AUTHENTICATOR");
}
String groupname = getArgument("groupname");
if (groupname == null) {
throw new InvalidArgumentException("Require groupname");
}
String command = "GROUP";
if (groupname != null) command += " -groupname " + groupname;
srv.send(command);
return srv.getResponse();
}
}
2020-10-12
魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐


所有评论(0)