Package com.dtrules.xmlparser

Examples of com.dtrules.xmlparser.XMLPrinter


        HSSFWorkbook wb = new HSSFWorkbook(input);
        HSSFSheet sheet = wb.getSheetAt(0);

        // Open the EDD.xml output file
        String     tmpEDDfilename = rs.getWorkingdirectory()+tmpEDD;
        XMLPrinter xout = new XMLPrinter(new FileOutputStream(tmpEDDfilename));
       
        // Write out a header in the EDD xml file.
        xout.opentag("edd_header");
           xout.printdata("edd_create_stamp",
                new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss Z").format(new Date())
           );
           xout.printdata("Excel_File_Name",excelFileName);
        xout.closetag();
        xout.opentag("edd");

       
        // Get the indexes of the columns we need to write out the XML for this EDD.
        int rows = sheet.getLastRowNum();
        int entityIndex    = findvalue("entity",sheet,0);
        int attributeIndex = findvalue("attribute",sheet,0);
        int typeIndex      = findvalue("type",sheet,0);
        int subtypeIndex   = findvalue("subtype",sheet,0);
        int defaultIndex   = findvalue("defaultvalue",sheet,0);
        int inputIndex     = findvalue("input",sheet,0);
        int accessIndex    = findvalue("access",sheet,0);
        int commentIndex   = findvalue("comment",sheet,0);      // optional
        int sourceIndex    = findvalue("source",sheet,0);       // optional
       
        // Some columns we just have to have.  Make sure we have them here.
        if(entityIndex <0 || attributeIndex < 0 || typeIndex < 0 || defaultIndex < 0 || accessIndex < 0 || inputIndex <0 ){
            String err = " Couldn't find the following column header(s): "+
              (entityIndex<0?" entity":"")+
              (attributeIndex<0?" attribute":"")+
              (typeIndex<0?" type":"")+
              (defaultIndex<0?" default value":"")+
              (accessIndex<0?" access":"")+
              (inputIndex<0?" input":"");
            throw new Exception("This EDD may not be valid, as we didn't find the proper column headers\n"+err);
        }
       
        // Go through each row, writing out each entry to the XML.
        for(int row = 1; row <=rows; row++){
            String entityname = getCellValue(sheet,row,entityIndex);    // Skip all the rows that have no Entity
            if(entityname.length()>0){
               
                String src     = sourceIndex>=0 ? getCellValue(sheet,row,sourceIndex):"";
                String comment = commentIndex>=0 ? getCellValue(sheet,row,commentIndex):"";
                xout.opentag("entry");
                xout.opentag("entity",
                        "entityname"        , entityname,
                        "attribute"         , getCellValue(sheet,row,attributeIndex),
                        "type"              , getCellValue(sheet,row,typeIndex),
                        "subtype"           , getCellValue(sheet,row,subtypeIndex),
                        "default"           , getCellValue(sheet,row,defaultIndex),
                        "access"            , getCellValue(sheet,row,accessIndex),
                        "input"             , getCellValue(sheet,row,inputIndex),
                        "comment"           , getCellValue(sheet,row,commentIndex)
                );
                xout.closetag();
                if(comment.length()>0)xout.printdata("comment",getCellValue(sheet,row,commentIndex));
                if(src    .length()>0 )xout.printdata("source", getCellValue(sheet,row,sourceIndex));
                xout.closetag();               
            }
        }
        xout.closetag();
        xout.close();
        convertEDD(ef,rs, tmpEDDfilename);
    }
View Full Code Here


                "condition_comment",      "condition_requirement",      "condition_description",
                "action_comment",         "action_requirement",         "action_description",
                "policy_description"};
       
        StripItDt(OutputStream out, String tags[]){
            this.out = new XMLPrinter(out);
            if(tags != null){
                this.tags = tags;
            }
        }
View Full Code Here

        XMLPrinter out;
       
        String     attributes[] = {"comment"};
       
        StripItEDD(OutputStream out, String attributes[]){
            this.out = new XMLPrinter(out);
            if(attributes != null){
                this.attributes = attributes;
            }
        }
View Full Code Here

        currentFile = f.getName();
        GenericXMLParser.load(new FileInputStream(f),new TraceLoad());
    }
   
    public void printReport(PrintStream o){
        XMLPrinter xout = new XMLPrinter(o);
      
        xout.opentag("coverage","total_columns_executed", totalColumns);
      
        xout.opentag("minimum_files_for_coverage");
        for(String file : minFilesNeeded){
            xout.printdata("trace_file",file);
        }
        xout.closetag();
       
        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();
    }
View Full Code Here

    static class ParseEDD extends AGenericXMLParser {
        XMLPrinter out;
               
        ParseEDD(OutputStream out){
            this.out = new XMLPrinter("test",out);
        }
View Full Code Here

           compareMapping(report);
       report.close();
   }
  
   public void compare(OutputStream reportStream) throws Exception {
       XMLPrinter report = new XMLPrinter(reportStream);
       compare(report);
   }
View Full Code Here

       compareDecisionTables(buff);
       return buff.toString();
   }
  
   public void compareDecisionTables(OutputStream reportStream) throws Exception {
       XMLPrinter report = new XMLPrinter(reportStream);
       compareDecisionTables(report);
   }
View Full Code Here

       return buff.toString();
   }
  
  
   public void compareEDD(OutputStream reportStream) throws Exception {
       XMLPrinter report = new XMLPrinter(reportStream);
       compareEDD(report);
   }
View Full Code Here

       return buff.toString();
   }
  
  
   public void compareMapping(OutputStream reportStream) throws Exception {
       XMLPrinter report = new XMLPrinter(reportStream);
       compareMapping(report);
   }
View Full Code Here

    /**
     * Print the TraceNode tree for this object.
     */
    public void print() {
        XMLPrinter out = new XMLPrinter(System.out);
        out.setSpaceCnt(2);
        if (root != null) {
            root.print(out);
        } else {
            System.out.println("No tree has been loaded");
        }
View Full Code Here

TOP

Related Classes of com.dtrules.xmlparser.XMLPrinter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.