WEB开发网
开发学院软件开发Java 基于 Eclipse 平台的代码生成技术 阅读

基于 Eclipse 平台的代码生成技术

 2010-07-02 00:00:00 来源:WEB开发网   
核心提示: 示例的模板内容如下清单 8. 示例模板内容<%@jetpackage="demo.translated"class="Demo3"%>packagedemo3;publicclass<%=((java.util.Map)argument)

示例的模板内容如下

清单 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"); 
 }

上一页  1 2 3 4 5 6 7 8 9 10  下一页

Tags:基于 Eclipse 平台

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接