真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

javajson代碼自動(dòng)生成(新建類)-創(chuàng)新互聯(lián)

package code;

import java.io.FileReader;
import java.io.FileWriter;
import java.io.LineNumberReader;
import java.util.ArrayList;
import java.util.List;

public class Code {

   private static List readFile(String filename)
   {
      List fileline = new ArrayList();

      try {

         FileReader in = new FileReader(filename);
         LineNumberReader reader = new LineNumberReader(in);

         String s = reader.readLine();
         while( s != null )
         {
            if(!s.startsWith("#"))
            {
               fileline.add(s);
            }
            s = reader.readLine();
         }

         reader.close();
         in.close();
      }catch(Exception e)
      {
         e.printStackTrace();
      }

      return fileline;
   }

   public static void genarateCode(List line)
   {
      String cr=" ";

      try{

         String [] data = line.get(1).split(",");
         FileWriter fw = new FileWriter(data[1]+".java");
         fw.write(cr);
         data = line.get(0).split(",");
         fw.write("package "+data[1]+cr);
         fw.write(cr);
         fw.write(cr);
         fw.write("import com.google.gson.annotations.SerializedName;"+cr);
         fw.write(cr);
         fw.write(cr);
         data = line.get(1).split(",");
         fw.write("public class "+data[1]+" {"+cr);
         fw.write(cr);
           for(int i = 2;i < line.size();i++)
         {
            data = line.get(i).split(",");
            if(data[1].trim().equalsIgnoreCase("int"))
            {
              fw.write("@SerializedName(""+data[0]+"")"+cr);
              fw.write("private Integer "+toLowerCaseFirst(data[0])+";"+cr);
            }
            else if(data[1].trim().equalsIgnoreCase("string"))
            {
               fw.write("@SerializedName(""+data[0]+"")"+cr);
               fw.write("private String "+toLowerCaseFirst(data[0])+";"+cr);
            }
            else
            {
              fw.write("@SerializedName(""+data[0]+"")"+cr);
              fw.write("private "+ data[1]+" "+toLowerCaseFirst(data[0])+";"+cr);
            }
         }

           fw.write(cr);
           fw.write(cr);

           for(int i = 2;i < line.size();i++)
          {
              data = line.get(i).split(",");
             if(data[1].trim().equalsIgnoreCase("int"))
             {
                fw.write("public void set"+data[0]+"(Integer value)"+cr);
                fw.write("{"+cr);
                fw.write("   "+toLowerCaseFirst(data[0])+" = "+"value;"+cr);
                fw.write("}"+cr);

                fw.write("public Integer get"+data[0]+"()"+cr);
                fw.write("{"+cr);
                fw.write("   return "+toLowerCaseFirst(data[0])+";"+cr);
                fw.write("}"+cr);
             }
             else if(data[1].trim().equalsIgnoreCase("string"))
             {
                fw.write("public void set"+data[0]+"(String value)"+cr);
              fw.write("{"+cr);
              fw.write("   "+toLowerCaseFirst(data[0])+" = "+"value;"+cr);
              fw.write("}"+cr);

              fw.write("public String get"+data[0]+"()"+cr);
              fw.write("{"+cr);
              fw.write("   return "+toLowerCaseFirst(data[0])+";"+cr);
              fw.write("}"+cr);
             }
           else
           {
              fw.write("public void set"+data[0]+"("+data[1]+" value)"+cr);
            fw.write("{"+cr);
            fw.write("   "+toLowerCaseFirst(data[0])+" = "+"value;"+cr);
            fw.write("}"+cr);

            fw.write("public "+data[1]+" get"+data[0]+"()"+cr);
            fw.write("{"+cr);
            fw.write("   return "+toLowerCaseFirst(data[0])+";"+cr);
            fw.write("}"+cr);
           }
          }
           fw.write(cr+cr);
           fw.write("} "+cr);
           fw.close();
      }catch(Exception e)
      {

      }
   }

   public static String toLowerCaseFirst(String str)
   {
      StringBuilder sb = new StringBuilder(str);
      sb.setCharAt(0, Character.toLowerCase(sb.charAt(0)));
      str = sb.toString();
      return str;
   }

   public static void main(String args[])
   {

      List fileline = readFile("field.txt");

        genarateCode(fileline);
        System.out.println("success!");

   }

}

成都創(chuàng)新互聯(lián)是專業(yè)的丹棱網(wǎng)站建設(shè)公司,丹棱接單;提供成都網(wǎng)站制作、成都網(wǎng)站設(shè)計(jì),網(wǎng)頁(yè)設(shè)計(jì),網(wǎng)站設(shè)計(jì),建網(wǎng)站,PHP網(wǎng)站建設(shè)等專業(yè)做網(wǎng)站服務(wù);采用PHP框架,可快速的進(jìn)行丹棱網(wǎng)站開發(fā)網(wǎng)頁(yè)制作和功能擴(kuò)展;專業(yè)做搜索引擎喜愛的網(wǎng)站,專業(yè)的做網(wǎng)站團(tuán)隊(duì),希望更多企業(yè)前來合作!field.txtjavajson代碼自動(dòng)生成(新
建類)

package,class
class,class
ContentList,List

version,int

name,String


名稱欄目:javajson代碼自動(dòng)生成(新建類)-創(chuàng)新互聯(lián)
文章源于:http://weahome.cn/article/cdpipd.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部