Diff for /FM2SQL/Attic/Convert.java between versions 1.68 and 1.69

version 1.68, 2004/08/05 11:17:10 version 1.69, 2004/08/06 11:15:41
Line 31  import java.sql.Statement; Line 31  import java.sql.Statement;
 import java.sql.Types;  import java.sql.Types;
 import java.text.ParseException;  import java.text.ParseException;
 import java.util.ArrayList;  import java.util.ArrayList;
   import java.util.Hashtable;
 import java.util.Iterator;  import java.util.Iterator;
 import java.util.List;  import java.util.List;
 import java.util.Properties;  
 import java.util.StringTokenizer;  import java.util.StringTokenizer;
 import java.util.TreeSet;  import java.util.TreeSet;
 import java.util.Vector;  import java.util.Vector;
Line 41  import java.util.Vector; Line 41  import java.util.Vector;
 import com.exploringxml.xml.Node;  import com.exploringxml.xml.Node;
 import com.exploringxml.xml.Xparse;  import com.exploringxml.xml.Xparse;
   
   
 class Convert  class Convert
 {  {
     /**Helper class for index creation
      * @author rogo
      *
      */
     public static class IndexList extends Vector
     {
       public String toString()
       {
         StringBuffer buff = new StringBuffer(1000);
         int count = 0;
         for (Iterator iter = this.iterator(); iter.hasNext();)
         {
           String element = (String) iter.next();
           if (count < elementCount-1)
           {
             buff.append(element).append(", ");
             count++;
           } else
             buff.append(element);
   
         }
   
         return buff.toString();
       }
     }
   static DBBean bean = new DBBean();    static DBBean bean = new DBBean();
   static DBBean beanDest = new DBBean();    static DBBean beanDest = new DBBean();
   
Line 1127  class Convert Line 1153  class Convert
     Vector selects = new Vector();      Vector selects = new Vector();
     Vector creates = new Vector();      Vector creates = new Vector();
     Vector ids = new Vector();      Vector ids = new Vector();
       Vector indexListVec= new Vector();
     String delimiter = "|";      String delimiter = "|";
     int mode = -1;      int mode = -1;
   
Line 1146  class Convert Line 1173  class Convert
         selects = new Vector();          selects = new Vector();
         creates = new Vector();          creates = new Vector();
         ids = new Vector();          ids = new Vector();
           indexListVec= new Vector();
         // parse dataBase          // parse dataBase
         Node node = root.find("convert/source/database/url", new int[] { 1, 1, i, 1 });          Node node = root.find("convert/source/database/url", new int[] { 1, 1, i, 1 });
         Node node1 = root.find("convert/source/database/user", new int[] { 1, 1, i, 1, 1 });          Node node1 = root.find("convert/source/database/user", new int[] { 1, 1, i, 1, 1 });
Line 1220  class Convert Line 1248  class Convert
           String name = (String) node4.attributes.get("name");            String name = (String) node4.attributes.get("name");
           String layout = (String) node4.attributes.get("layout");            String layout = (String) node4.attributes.get("layout");
           String id = (String) node4.attributes.get("id");            String id = (String) node4.attributes.get("id");
             String indexList = (String) node4.attributes.get("indexList");
         
           System.out.println("id was " + id);            System.out.println("id was " + id);
           if (name == null)            if (name == null)
             throw new Error("parse error required table tag attribute name missing");              throw new Error("parse error required table tag attribute name missing");
Line 1227  class Convert Line 1257  class Convert
             layout = "";              layout = "";
           if (id == null)            if (id == null)
             id = "";              id = "";
             if(indexList==null)
             indexList="";
           if (name.equals(""))            if (name.equals(""))
             throw new Error("parse error table tag attribute must not be empty");              throw new Error("parse error table tag attribute must not be empty");
           tables.add(name);            tables.add(name);
           layouts.add(layout);            layouts.add(layout);
             
           ids.add(id);            ids.add(id);
             indexListVec.add(indexList);
           String query = (node5 == null) ? "" : node5.getCharacters();            String query = (node5 == null) ? "" : node5.getCharacters();
           if (query.equals(""))            if (query.equals(""))
             System.err.println("Warning empty select tag or  select tag missing !!");              System.err.println("Warning empty select tag or  select tag missing !!");
Line 1245  class Convert Line 1279  class Convert
         }          }
         DataBase dataBase = new DataBase(database, tables, layouts, selects, creates, ids, mode);          DataBase dataBase = new DataBase(database, tables, layouts, selects, creates, ids, mode);
         dataBase.delimiter = delimiter;          dataBase.delimiter = delimiter;
           dataBase.buildIndexTable(indexListVec);
         databases.add(dataBase);          databases.add(dataBase);
       }        }
       DBBean database = new DBBean();        DBBean database = new DBBean();
Line 1575  class Convert Line 1610  class Convert
     Vector tables;      Vector tables;
     Vector ids;      Vector ids;
     String delimiter = "//";      String delimiter = "//";
       /**
        * maps table name to index fields
        */
       Hashtable htIndex = new Hashtable();
     boolean useNormanToUnicodeMapper = false;      boolean useNormanToUnicodeMapper = false;
   
     final static int CONVERT_MODE = 1;      final static int CONVERT_MODE = 1;
Line 1597  class Convert Line 1636  class Convert
       this.bean.setIDVector(ids);        this.bean.setIDVector(ids);
     }      }
     /**      /**
        * @param indexListVec
        */
       public void buildIndexTable(Vector indexListVec)
       {
          for (int i = 0; i < tables.size(); i++)
         {
           fillIndexList((String)tables.get(i),(String)indexListVec.get(i));
         }    
       }
       /**
      * writes the data contained in this object to the buffered writer       * writes the data contained in this object to the buffered writer
      * * @param buffr       * * @param buffr
      * @throws Exception       * @throws Exception
Line 1630  class Convert Line 1679  class Convert
         String select = (String) selects.get(index);          String select = (String) selects.get(index);
         String create = (String) creates.get(index);          String create = (String) creates.get(index);
         String id = (String) ids.get(index);          String id = (String) ids.get(index);
           IndexList indexList = (IndexList) htIndex.get(table);
         buffr.write("      <table name = \"" + table + "\" layout = \"" + layout + "\" id = \"" + id + "\" >\n");          if (indexList == null)
             indexList = new IndexList();
           buffr.write("      <table name = \"" + table + "\" layout = \"" + layout + "\" id = \"" + id + "\" indexList =\"" + indexList + "\">\n");
         buffr.write("         <select>" + convertToEntities(select) + "</select>\n");          buffr.write("         <select>" + convertToEntities(select) + "</select>\n");
         if (!create.equals(""))          if (!create.equals(""))
           buffr.write("         <create>" + create + "         </create>\n");            buffr.write("         <create>" + create + "         </create>\n");
Line 1640  class Convert Line 1691  class Convert
       }        }
       buffr.write("    </database>\n");        buffr.write("    </database>\n");
     }      }
   
       public void fillIndexList(String table, String list)
       {
         IndexList indexList = new IndexList();
         StringTokenizer tokenizer = new StringTokenizer(list, ",");
         while (tokenizer.hasMoreTokens())
         {
           indexList.add(tokenizer.nextToken());
         }
         System.out.println(indexList);
     
       htIndex.put(table, indexList);
       }
     public String toString()      public String toString()
     {      {
       return bean.url + " " + tables;        return bean.url + " " + tables;

Removed from v.1.68  
changed lines
  Added in v.1.69


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>