private void coverage(File f) throws Exception {
GenericXMLParser.load(new FileInputStream(f),new TraceLoad());
}
public void printReport(PrintStream o){
XMLPrinter xout = new XMLPrinter(o);
xout.opentag("coverage");
xout.opentag("trace_files");
for(String file : traceFilesProcessed){
xout.printdata("trace_file",file);
}
xout.closetag();
Object keys[] = tables.keySet().toArray();
for(int i=0;i<keys.length-1;i++){
for(int j=0;j<keys.length-1-i;j++){
if(keys[j].toString().compareTo(keys[j+1].toString())>0){
Object hld = keys[j];
keys[j] = keys[j+1];
keys[j+1] = hld;
}
}
}
xout.opentag("tables");
for(Object key : keys){
Stats stats = tables.get(key);
int total_columns = 0;
int columns_covered = 0;
if(stats.table.getHasNullColumn()){
total_columns ++;
}
if(stats.noColumns>0){
columns_covered++;
}
for(int i=0; i< stats.columnCount; i++){
if(stats.table.getColumnsSpecified()[i]){
total_columns++;
if( stats.columnHits[i]>0){
columns_covered++;
}
}
}
double fpercent = ((double) columns_covered / total_columns)*100.0;
int percent = (int) fpercent;
int fraction = (int) ((fpercent - percent)*100);
xout.opentag("table","name",key,"count_of_calls",stats.calledCount, "percent_covered",percent+"."+fraction);
if(stats.table.getHasNullColumn()){
xout.printdata("column","n","none","hits",stats.noColumns,null);
}
for(int i=0; i< stats.columnCount; i++){
if(stats.table.getColumnsSpecified()[i]){
xout.printdata("column","n",i+1,"hits",stats.columnHits[i],null);
}
}
xout.closetag();
}
xout.closetag();
xout.closetag();
}