//package xml; import org.w3c.dom.*; import java.util.Vector; import java.util.Hashtable; import java.util.Enumeration; import java.util.Stack; import java.util.Date; import java.io.PrintStream; import java.net.*; /** * * @date September 26, 1998 ( Last Updated September 26, 1998 ) * @author H. Timucin Ozdemir * */ public class TestsDocument extends BaseDocument implements XMLDebugFlags, AlgorithmsConstants { Hashtable tests; /** isExtracted? */ boolean isExtracted = true; /** org.w3c.dom.Document */ Document dom; /** */ public TestsDocument(Document _dom) { tests = new Hashtable(); dom = _dom; }// end of CONSTRUCTOR /** */ public Enumeration getTests() { if(isExtracted) extractFromDocument(); return tests.elements(); }// end of getRegisteredComponents() /** */ public void extractFromDocument() { if(DEBUG) System.out.println(" in extractFromDocument() "); isExtracted = false; if(dom!=null) { Element componentsRoot = dom.getDocumentElement(); if( componentsRoot.getTagName().equals(testsLbl) ) extractItems(componentsRoot); } else System.out.println(" Document is NULL1"); if(DEBUG) System.out.println(" out of extractFromDocument() "); }// end of extractFromDocument() /** */ final void extractItems(Element componentsRoot) { if(DEBUG) System.out.println(" in extractItems() "); NodeList componentList = ((Node)componentsRoot).getChildNodes(); Node current=null; int i=0; TestRecord a=null; if( componentList!=null && componentList.getLength()>0) { while( i"); Enumeration e = tests.elements(); while( e.hasMoreElements() ) { AlgorithmRecord imItem = (AlgorithmRecord) e.nextElement(); if( imItem!=null ) imItem.print(o); }// end of while o.println( ""); }// end of print() /** */ public void printHTML1(PrintStream o) { //o.println( "<"+testsLbl+">"); Hashtable results = new Hashtable(); Enumeration e = tests.elements(); while( e.hasMoreElements() ) { AlgorithmRecord a = (AlgorithmRecord) e.nextElement(); if( a!=null ) { results.put(a.getAlgorithmName(),a); System.out.println( "Algorithm "+a.getAlgorithmName()+" is added!"); } }// end of while //o.println( ""); printHTML1(results,o); }// end of print() /** */ public void printTableHeader(Enumeration e, PrintStream o) { o.println("

"); o.println(""); while( e.hasMoreElements() ) { String s = (String) e.nextElement(); if( s!=null ) o.println(""); ; }// end of while o.println(""); } /** */ public void printTableHeader(String[] s, PrintStream o) { o.println("

"+s+"
"); o.println(""); for(int i=0;i"+s+""); ; o.println(""); } /** */ public void printHTML1(Hashtable a, PrintStream o) { //o.println( "<"+testsLbl+">"); int i=0; Hashtable results = new Hashtable(); o.println(""); o.println(""); Date pdate = new Date(System.currentTimeMillis() ); o.println(" Produced on :"+pdate+""); //o.println("
"); Enumeration e = a.keys(); //o.println(""); String[] algNames = new String[a.size()]; while( e.hasMoreElements() ) { String s = (String) e.nextElement(); if( s!=null ) algNames[i++]=new String(s); }// end of while //o.println(""); for(i=0;i"); printTableHeader(a.keys(),o); printHTML1(C2,algNames,a,o); o.println("
"); printTableHeader(a.keys(),o); printHTML1(R1,algNames,a,o); o.println(""); printTableHeader(a.keys(),o); printHTML1(R2,algNames,a,o); o.println(""); printTableHeader(a.keys(),o); printHTML1(RC1,algNames,a,o); o.println(""); printTableHeader(a.keys(),o); printHTML1(RC2,algNames,a,o); o.println(""); o.println(""); o.println(""); }// end of print() /** */ public void printHTML1(String[] prob,String[] algNames, Hashtable a, PrintStream o) { AlgorithmRecord algRec; for(int j=0;j"); o.println( ""+prob[j]+""); for(int i=0;i"+prec.getTDistance()+""); else o.println( "___"); }// end of if } o.println( ""); } }// end of print() /** */ public void printXML(PrintStream o) { //o.println( "<"+testsLbl+">"); Hashtable results = new Hashtable(); Enumeration e = tests.elements(); while( e.hasMoreElements() ) { TestRecord a = (TestRecord) e.nextElement(); if( a!=null ) { Vector b = (Vector) results.get(a.getAlgorithmName()); if(b==null) { b=new Vector(); results.put(a.getAlgorithmName(),b); } b.addElement(a); System.out.println( "Algorithm "+a.getAlgorithmName()+" is added! for:"+a.getProblemName()); } }// end of while o.println( ""); o.println( "<"+AlgorithmsLabel+">"); e=results.keys(); while( e.hasMoreElements() ) { String aKey = (String) e.nextElement(); if( aKey!=null ) { Vector a = (Vector)results.get(aKey); if(a!=null) printTextRecordXML(aKey,a.elements(),o); } }// end of while o.println( ""); //o.println( ""); //printHTML1(results,o); }// end of print() /** */ public void printTextRecordXML(String algName, Enumeration e, PrintStream o) { o.println( " <"+AlgorithmItemLabel+" "+nameLabel+"=\""+algName+"\">"); while( e.hasMoreElements() ) { TestRecord a = (TestRecord) e.nextElement(); if( a!=null ) { o.println(" "); } }// end of while o.println( " "); }// end of print() }// end of ImRDocument