⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 application.java

📁 exemple for Document Object Model DOM
💻 JAVA
字号:
package mod鑜es;
import java.util.Vector;

//import mod鑜es.*;

public class Application {
	
	@SuppressWarnings("unchecked")
	public static void main (String args[]) throws Exception
	{
		FichierSortie fichierSortie = new FichierSortie();
		Convertisseur conv;
		conv =new Convertisseur();
		conv.addType("string","varchar(250)");
		conv.addType("boolean","boolean");
		conv.addType("float","float");
		conv.addType("double","double");
		conv.addType("decimal","decimal");
        conv.addType("short","decimal");
		conv.addType("duration","timestamp");
		conv.addType("dateTime","timestamp");
		conv.addType("time","time");	
		conv.addType("date","date");
		conv.addType("gYearMonth","char(7)");		
		conv.addType("gYear","smallint");
		conv.addType("gMonthDay","char(5)");
		conv.addType("gDay","decimal");
		conv.addType("gMonth","decimal");	
		conv.addType("hexBinary","binary(4)");
		conv.addType("base64Binary","binary(4)");
		conv.addType("anyURI","varchar(250)");
		conv.addType("QName","varchar(250)");
		conv.addType("NOTATION","varchar(250)");
		
		Table uneTable = new Table();
		Vector valeurChamps = new Vector();
		Vector autres = new Vector();
		Vector Typechamps = new Vector();
		Vector champsTable = new Vector();
		@SuppressWarnings("unused")
		Vector temp = null;
		@SuppressWarnings("unused")
		ChampTable unChamptable = null;
		@SuppressWarnings("unused")
		int j,k = 0;
		int nbreChamps = 0;
		MyParser analysefichier = null;
		String ficherAparser[] = {"fichiers/cours.xml","fichiers/coursSchema.xsd","fichiers/eleves.xml","fichiers/elevesSchema.xsd"};
		//Parse each file provided on the command line.
	      for (int i = 0; i < ficherAparser.length; i++){
	    	  System.out.print("---------------------- " + ficherAparser[i] + " (d閎ut du traitement) ----------------------" + "\n");
	    	  analysefichier = new MyParser(ficherAparser[i]);
	    	  analysefichier.parsingFile();
	    	  
	    	  if(i%2==1){//on parse le sch閙a du fichier xml
	    		  Typechamps = new Vector(analysefichier.rendreTypeChamps());
	    		  temp = new Vector(uneTable.getChampsTable());
	    		  for (j=0;j<uneTable.getnbreDeChamps();j++){
	    			  //avec convertion
	    			  ((ChampTable)uneTable.getChampsTable().elementAt(j)).settypeChamp(  conv.convertir((String)Typechamps.elementAt(j))  );	    			  
//	    			  //sans convertion
	    			  //((ChampTable)uneTable.getChampsTable().elementAt(j)).settypeChamp((String) Typechamps.elementAt(j)  );
	    		  }
	    	  }
	    	  else {//on parse le fichier xml
	    		  nbreChamps = 0;
	    		  unChamptable = new ChampTable();
	    		  champsTable = new Vector();
		    	  
	    		  
	    		  //on r閏up鑢e toutes les donn閑s des fichiers pars閟
		    	  autres = new Vector(analysefichier.rendreAutres());
		    	  valeurChamps = new Vector(analysefichier.rendreValeurChamps());
		    	  //on compte le nombre de champs qu'il y a dans la bd
		    	  j=2;
	    		  while (((String)autres.elementAt(j)).equals((String)autres.elementAt(1))==false) {
	    			  nbreChamps++;
	    			  j++;
	    		  }
	    		  for(j=0;j<nbreChamps;j++){
	    			  champsTable.addElement(new ChampTable((String)autres.elementAt(j+2),""));
	    		  }
	    		  
		    	  uneTable.setnomTable((String)autres.elementAt(1));		    	  
		    	  uneTable.setnbreDeChamps(nbreChamps);
		    	  uneTable.setChampsTable(champsTable);
		    	  valeurChamps = analysefichier.rendreValeurChamps();
	    	  }
	    	  AfficherTable(uneTable);
		      fichierSortie.ouvertureFichierSortie(uneTable.getnomTable());
		      fichierSortie.ecritureCreateTable(uneTable);
		      fichierSortie.ecritureInsertTable(valeurChamps, uneTable);
		      fichierSortie.fermetureFichierSortie();
		      System.out.print("---------------------- (fin du traitement) ----------------------" + "\n");
	    	  
	      }
	     
	}
	
	/**
	 * Fonction utlis閑 lors des test, elle permettait simplement 
	 * d'affichier le CREATE de la table.
	 * @param uneTable
	 */
	public static void AfficherTable(Table uneTable){
		int i = 0;
		System.out.println("\nInformations sur la table");
		System.out.println("CREATE TABLE  " + uneTable.getnomTable() + " {");		
		for(i=0;i<uneTable.getChampsTable().size();i++){
			System.out.print("\t" + ((ChampTable)uneTable.getChampsTable().elementAt(i)).getnomChamp()   + " "+ ((ChampTable)uneTable.getChampsTable().elementAt(i)).gettypeChamp());
			if (i+1 < uneTable.getChampsTable().size()){
				System.out.println(",");
			}
			else{
				System.out.println("");
			}
		}
		System.out.println("};\n");
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -