.#createtotal.java.1.5
来自「xmlwenjian xmlwenjian xmlwenjian xmlwenj」· 5 代码 · 共 167 行
5
167 行
package com.create;
import java.io.File;
import java.io.FileWriter;
//该类调用其他类协同完成所有界面的生成
public class CreateTotal {
public static String allPath = "D:\\Analyze\\T_PLACE.xml"; //XML绝对路径
// public static String allPath = "D:\\Analyze\\T_COLOR.xml"; //XML绝对路径
public static String basePath = "D:\\Analyze"; //生成文件的绝对路径
public CreateTotal(){}
public CreateTotal(String xmlpath,String basepath){
this.allPath = xmlpath;
this.basePath = basepath;
}
//从xml中提取数据到Bean中,初始化公共变量。(其实此时Bean已经没用了。)
PublicVar pubvar = new PublicVar(allPath,basePath);
File outf = null;
FileWriter fw = null;
String str = "";
int i = 0;
public void createTotalSingle(){
int flg = 0;
flg = createSingleList(); if(flg==1){ System.out.println("单表List页面完成!"); } flg = 0;
flg = createSingleInput(); if(flg==1){ System.out.println("单表Input页面完成!"); } flg = 0;
flg = createSingAction(); if(flg==1){ System.out.println("单表Action页面完成!"); } flg = 0;
flg = createSingActiond(); if(flg==1){ System.out.println("单表Actiond页面完成!");} flg = 0;
flg = createSingleAdo(); if(flg==1){ System.out.println("单表Ado页面完成!"); } flg = 0;
flg = createConfig(false); if(flg==1){ System.out.println("单表配置路径已建立!"); } flg = 0;
}
public void createTotalMutil(){
int flg = 0;
flg = createMutilList(); if(flg==1){ System.out.println("多表List页面完成!"); } flg = 0;
flg = createMutilInput(); if(flg==1){ System.out.println("多表Input页面完成!"); } flg = 0;
flg = createMutilAction(); if(flg==1){ System.out.println("多表Action页面完成!"); } flg = 0;
flg = createMutilActiond(); if(flg==1){ System.out.println("多表Actiond页面完成!");} flg = 0;
flg = createMutilAdo(); if(flg==1){ System.out.println("多表Ado页面完成!"); } flg = 0;
flg = createConfig(true); if(flg==1){ System.out.println("多表配置路径已建立!"); } flg = 0;
}
public int createConfig(boolean ff){
String path = PublicVar.basePath+"\\"+"Config.txt";
try{
if(ff) { str = "<!-- "+PublicVar.title1 +"&&" + PublicVar.title2 +" 双表-->\r\n"; }
else { str = "<!-- "+PublicVar.title1 +" 单表-->\r\n"; }
str = str + "<action path=\"/"+PublicVar.folderName+"/"+PublicVar.hibernatename1+"Action\" type=\"com.hssysway."+PublicVar.folderName+".action."+PublicVar.hibernatename1+"Action\" />\r\n";
str = str + "<action path=\"/"+PublicVar.folderName+"/"+PublicVar.hibernatename1+"Actiond\" type=\"com.hssysway."+PublicVar.folderName+".action."+PublicVar.hibernatename1+"Actiond\" />\r\n";
outf = new File(path);
outf.getParentFile().mkdirs();fw = new FileWriter(outf,true);fw.write(str);fw.close();i = 1;
}catch(Exception e){System.out.println("创建配置路径出错!");i = 0;}
return i;
}
public int createSingleList(){
String path = PublicVar.basePath+"\\"+PublicVar.folderName+"\\"+PublicVar.hibernatename1+"List.jsp";
try{
str = new singList().createPage();
outf = new File(path);
outf.getParentFile().mkdirs();fw = new FileWriter(outf);fw.write(str);fw.close();i = 1;
}catch(Exception e){System.out.println("创建单表List页面出错!");i = 0; e.printStackTrace();}
return i;
}
public int createSingleInput(){
String path = PublicVar.basePath+"\\"+PublicVar.folderName+"\\"+PublicVar.hibernatename1+"Input.jsp";
try{
str = new singInput().createPage();
outf = new File(path);
outf.getParentFile().mkdirs();fw = new FileWriter(outf);fw.write(str);fw.close();i = 1;
}catch(Exception e){System.out.println("创建单表Input页面出错!");i = 0; e.printStackTrace();}
return i;
}
public int createMutilList(){
String path = PublicVar.basePath+"\\"+PublicVar.folderName+"\\"+PublicVar.hibernatename1+"List.jsp";
try{
str = new mutilList().createPage();
outf = new File(path);
outf.getParentFile().mkdirs();fw = new FileWriter(outf);fw.write(str);fw.close();i = 1;
}catch(Exception e){System.out.println("创建多表List页面出错!");i = 0; e.printStackTrace();}
return i;
}
public int createMutilInput(){
String path = PublicVar.basePath+"\\"+PublicVar.folderName+"\\"+PublicVar.hibernatename1+"Input.jsp";
try{
str = new mutilInput().createPage();
outf = new File(path);
outf.getParentFile().mkdirs();fw = new FileWriter(outf);fw.write(str);fw.close();i = 1;
}catch(Exception e){System.out.println("创建多表Input页面出错!");i = 0; e.printStackTrace();}
return i;
}
public int createSingAction(){
String path = PublicVar.basePath+"\\"+PublicVar.actionPath+"\\"+PublicVar.hibernatename1+"Action.java";
try{
str = new singAction().createPage();
outf = new File(path);
outf.getParentFile().mkdirs();fw = new FileWriter(outf);fw.write(str);fw.close();i = 1;
}catch(Exception e){System.out.println("创建单表Action页面出错!");i = 0;}
return i;
}
public int createSingActiond(){
String path = PublicVar.basePath+"\\"+PublicVar.actionPath+"\\"+PublicVar.hibernatename1+"Actiond.java";
try{
str = new singActiond().createPage();
outf = new File(path);
outf.getParentFile().mkdirs();fw = new FileWriter(outf);fw.write(str);fw.close();i = 1;
}catch(Exception e){System.out.println("创建单表Actiond页面出错!");i = 0;}
return i;
}
public int createMutilAction(){
String path = PublicVar.basePath+"\\"+PublicVar.actionPath+"\\"+PublicVar.hibernatename1+"Action.java";
try{
str = new mutilAction().createPage();
outf = new File(path);
outf.getParentFile().mkdirs();fw = new FileWriter(outf);fw.write(str);fw.close();i = 1;
}catch(Exception e){System.out.println("创建多表Action页面出错!");i = 0;}
return i;
}
public int createMutilActiond(){
String path = PublicVar.basePath+"\\"+PublicVar.actionPath+"\\"+PublicVar.hibernatename1+"Actiond.java";
try{
str = new mutilActiond().createPage();
outf = new File(path);
outf.getParentFile().mkdirs();fw = new FileWriter(outf);fw.write(str);fw.close();i = 1;
}catch(Exception e){System.out.println("创建多表Actiond页面出错!");i = 0; e.printStackTrace();}
return i;
}
public int createSingleAdo(){
String path = PublicVar.basePath+"\\"+PublicVar.adoPath+"\\"+PublicVar.hibernatename1+"ADO.java";
try{
str = new singAdo().createPage();
outf = new File(path);
outf.getParentFile().mkdirs();fw = new FileWriter(outf);fw.write(str);fw.close();i = 1;
}catch(Exception e){System.out.println("创建单表Ado页面出错!");i = 0;}
return i;
}
public int createMutilAdo(){
String path = PublicVar.basePath+"\\"+PublicVar.adoPath+"\\"+PublicVar.hibernatename1+"ADO.java";
try{
str = new mutilAdo().createPage();
outf = new File(path);
outf.getParentFile().mkdirs();fw = new FileWriter(outf);fw.write(str);fw.close();i = 1;
}catch(Exception e){System.out.println("创建多表Ado页面出错!");i = 0;}
return i;
}
public static void main(String args[]){
CreateTotal ct = new CreateTotal();
System.out.println("存放文件绝对路径:"+PublicVar.basePath);
System.out.println("hibernate包路径:"+PublicVar.hibernatePackage);
System.out.println("文件夹路径:"+PublicVar.folderName);
System.out.println("action包路径:"+PublicVar.actionPackage);
System.out.println("action文件:"+PublicVar.actionPath);
System.out.println("ado包路径:"+PublicVar.adoPackage);
System.out.println("ado文件路径:"+PublicVar.adoPath);
System.out.println("单表List文件全路径:"+PublicVar.basePath+"\\"+PublicVar.folderName+"\\"+PublicVar.hibernatename1+"List.jsp");
System.out.println("多表List文件全路径:"+PublicVar.basePath+"\\"+PublicVar.folderName+"\\"+PublicVar.hibernatename1+"List.jsp");
System.out.println("单表Input文件全路径:"+PublicVar.basePath+"\\"+PublicVar.folderName+"\\"+PublicVar.hibernatename1+"Input.jsp");
System.out.println("多表Input文件全路径:"+PublicVar.basePath+"\\"+PublicVar.folderName+"\\"+PublicVar.hibernatename1+"Input.jsp");
System.out.println("单表Action文件全路径:"+PublicVar.basePath+"\\"+PublicVar.actionPath+"\\"+PublicVar.hibernatename1+"Action.java");
System.out.println("单表Actiond文件全路径:"+PublicVar.basePath+"\\"+PublicVar.actionPath+"\\"+PublicVar.hibernatename1+"Actiond.java");
System.out.println("多表Action文件全路径:"+PublicVar.basePath+"\\"+PublicVar.actionPath+"\\"+PublicVar.hibernatename1+"Action.java");
System.out.println("多表Actiond文件全路径:"+PublicVar.basePath+"\\"+PublicVar.actionPath+"\\"+PublicVar.hibernatename1+"Actiond.java");
System.out.println("单表Ado文件全路径:"+PublicVar.basePath+"\\"+PublicVar.adoPath+"\\"+PublicVar.hibernatename1+"Ado.java");
System.out.println("多表Ado文件全路径:"+PublicVar.basePath+"\\"+PublicVar.adoPath+"\\"+PublicVar.hibernatename1+"Ado.java");
ct.createTotalSingle();
// ct.createTotalMutil();
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?