📄 buildwebvomain.java
字号:
////Edit by wjliu in 2005-03-31
import java.io.*;
public class BuildWebVOMain{
public static void main( String[] args ){
String[] eleArray = new String[9];
eleArray[0] = "bordId";
eleArray[1] = "bbsName";
eleArray[2] = "newTime";
eleArray[3] = "bbsAdmin";
eleArray[4] = "bbspass";
eleArray[5] = "messageCount";
eleArray[6] = "titleCount";
eleArray[7] = "lastUser";
eleArray[8] = "lastTime";
//eleArray[9] = "questionUser";
//eleArray[10] = "questionTime";
//eleArray[11] = "onLine";
buildWebVO( "BbsVO.java", eleArray );
}
public static void buildWebVO( String voName, String[] eleArray ){
if( voName == null ){
System.out.println( "voName == [null]" );
return;
}
if( voName.equals( "" ) ){
System.out.println( "voName == []" );
}
String voClassName = voName.substring( 0, voName.indexOf( "." ) );
try{
File webVOFile = new File( voName );
System.out.println( "voFile is:"+webVOFile.createNewFile() );
FileOutputStream out = new FileOutputStream( webVOFile );
PrintWriter writer = new PrintWriter( out );
writer.println( "//build by alloha" );
writer.println( "package my.WebVO;" );
writer.println( "" );
writer.println( "import java.util.ArrayList;" );
writer.println( "" );
writer.println( "public class "+voClassName+"{" );
writer.println( "" );
for( int i=0; i<eleArray.length; i++ ){
writer.println( " private String "+eleArray[i]+";" );
}
writer.println( " private ArrayList InfoList = new ArrayList();" );
writer.println( "" );
writer.println( " public "+voClassName+"(){" );
for( int i=0; i<eleArray.length; i++ ){
writer.println( " "+eleArray[i] +" = \"\";" );
}
writer.println( " }" );
writer.println( "" );
writer.println( "/////////////////////////////////////////////////////////" );
writer.println( "/////////////////////////////////////////////////////////" );
writer.println( "" );
String functionName = "";
char firstChar;
for( int i=0; i<eleArray.length; i++ ){
firstChar = eleArray[i].charAt(0);
//System.out.println( "firstChar:"+firstChar );
/*
if( firstChar<='z' && firstChar >= 'a' ){
firstChar = (char)((int)firstChar - 32);
}
*/
//System.out.println( "firstChar:"+firstChar );
functionName = firstChar+eleArray[i].substring( 1, eleArray[i].length() );
writer.println( " public void set_"+functionName+"(String "+eleArray[i]+"){" );
writer.println( " if( "+eleArray[i]+" == null ){" );
writer.println( " return;" );
writer.println( " }" );
writer.println( "" );
writer.println( " this."+eleArray[i]+"="+eleArray[i]+".trim();" );
writer.println( " }" );
writer.println( "" );
writer.println( " public void set_"+functionName+"( int index, String "+eleArray[i]+" ){" );
writer.println( " if( index < 0 ){" );
writer.println( " return;" );
writer.println( " }" );
writer.println( "" );
writer.println( " if( "+eleArray[i]+" ==null ){" );
writer.println( " return;" );
writer.println( " }" );
writer.println( "" );
writer.println( " ((String[])InfoList.get( index ))["+i+"] = new String( "+eleArray[i]+".trim() );" );
writer.println( " }" );
writer.println( "" );
writer.println( " public String get_"+functionName+"(){" );
////Edit by wjliu in 2005-03-31
// writer.println( " return this."+eleArray[i]+".trim();" );
writer.println( " return this."+eleArray[i]+";" );
writer.println( " }" );
writer.println( "" );
writer.println( " public String get_"+functionName+"( int index ){" );
writer.println( " if( index < 0 ){" );
writer.println( " return (\"\"+index);" );
writer.println( " }" );
////Edit by wjliu in 2005-03-31
// writer.println( " return ((String[])(InfoList.get( index )))["+i+"].trim();" );
writer.println( " return ((String[])(InfoList.get( index )))["+i+"];" );
writer.println( " }" );
writer.println( "" );
writer.println( "/////////////////////////////////////////////////" );
writer.println( "/////////////////////////////////////////////////" );
writer.println( "" );
}
writer.println( " public void add(){" );
writer.println( " String[] InfoArray = new String["+eleArray.length+"];" );
for( int i=0; i<eleArray.length; i++ ){
writer.println( " InfoArray["+i+"] = new String( "+eleArray[i]+" );" );
}
writer.println( "" );
writer.println( " InfoList.add( InfoArray );" );
writer.println( "" );
for( int i=0; i<eleArray.length; i++ ){
writer.println( " "+eleArray[i]+" = \"\";" );
}
writer.println( " }" );
writer.println( "" );
writer.println( " public int size(){" );
writer.println( " return InfoList.size();" );
writer.println( " }" );
writer.println( "" );
writer.println( " public void remove( int index ){" );
writer.println( " InfoList.remove( index );" );
writer.println( " }" );
writer.println( "}" );
writer.close();
out.close();
}catch( Exception e ){
e.printStackTrace();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -