Coverage Report - org.wiztools.xml2spreadsheet.XML2SpreadSheet
 
Classes in this File Line Coverage Branch Coverage Complexity
XML2SpreadSheet
50% 
N/A 
1
 
 1  
 /*
 2  
  * XML2SpreadSheet.java
 3  
  *
 4  
  * Created on December 2, 2006, 5:08 PM
 5  
  *
 6  
  * To change this template, choose Tools | Template Manager
 7  
  * and open the template in the editor.
 8  
  */
 9  
 
 10  
 package org.wiztools.xml2spreadsheet;
 11  
 
 12  
 import java.io.File;
 13  
 import java.io.FileInputStream;
 14  
 import java.io.FileNotFoundException;
 15  
 import java.io.FileOutputStream;
 16  
 import java.io.IOException;
 17  
 import java.io.InputStream;
 18  
 import java.io.OutputStream;
 19  
 import org.wiztools.xml2spreadsheet.exception.XML2XLSFatalException;
 20  
 
 21  
 /**
 22  
  *
 23  
  * @author subhash
 24  
  */
 25  
 public final class XML2SpreadSheet {
 26  
     
 27  
     /** Creates a new instance of XML2SpreadSheet */
 28  0
     private XML2SpreadSheet() {
 29  0
     }
 30  
     
 31  
     /**
 32  
      * Accepts XML in the inputstream and outputs .xls in the output stream.
 33  
      *
 34  
      */
 35  
     public static void convert(InputStream in, OutputStream out) 
 36  
             throws FileNotFoundException,
 37  
             IOException,
 38  
             XML2XLSFatalException{
 39  
         
 40  12
         WorkBookCreator wbc = WorkBookCreatorFactory.getWorkBookCreator();
 41  12
         XML2XLSGenerator gen = new XML2XLSGenerator();
 42  
         // Following line is capable of throwing Exception:
 43  12
         gen.parse((WorkBookGenerationHandler)wbc, in);
 44  12
         WorkBook workBook = wbc.getWorkBook();
 45  12
         workBook.write(out);
 46  
         
 47  12
     }
 48  
 
 49  
     /**
 50  
      * Accepts input XML File as first parameter and outputs .xls as second File.
 51  
      * If file exists, will overwrite.
 52  
      */
 53  
     public static void convert(File in, File out) 
 54  
             throws FileNotFoundException,
 55  
             IOException,
 56  
             XML2XLSFatalException{
 57  0
         FileInputStream is_in = new FileInputStream(in);
 58  0
         FileOutputStream is_out = new FileOutputStream(out);
 59  0
         convert(is_in, is_out);
 60  0
     }
 61  
    
 62  
 }