基于 Eclipse 平台的代码生成技术
2010-07-02 00:00:00 来源:WEB开发网示例的模板内容如下
清单 8. 示例模板内容
<%@jet package="demo.translated" class="Demo3"%>
package demo3;
public class <%=((java.util.Map)argument).get("className")%> {
/**
* Target javadoc 11
* Target javadoc 14
*
* @generated
*/
public void printMessage1() {
// This is my owner code
System.out.print("Will be replace");
System.out.println("Source code 1");
}
/**
* Target javadoc 21
* Target javadoc 24
*
* @generated
*/
public void printMessage2() {
// This is my owner code
System.out.print("Will be replace");
System.out.println("Source code 2");
}
生成类加入手工代码后的代码
清单 9. 加入手工代码后的代码
/**
* Target javadoc 11
* Target javadoc 12
* Target javadoc 13
* Target javadoc 14
*
* @generated NOT this target delete or add a word NOT
*/
public void printMessage1() {
// This is my owner code
System.out.print("This is user code");
}
/**
* Target javadoc 21
* <!-- begin-user-doc -->
* Target javadoc 22
* Target javadoc 23
* <!-- end-user-doc -->
* Target javadoc 24
*
* @generated
*/
public void printMessage2() {
// This is my owner code
System.out.print("This code will be replace");
System.out.print("Will be replace");
System.out.println("Source code 2");
}
更多精彩
赞助商链接