1 package net.firstpartners.nounit.ui.common; 2 3 26 27 import java.io.File ; 28 import java.io.FileOutputStream ; 29 30 import net.firstpartners.nounit.reader.bytecode.ByteCodeProjectSnippetFactory; 31 import net.firstpartners.nounit.report.IReport; 32 import net.firstpartners.nounit.report.ReportPicker; 33 import net.firstpartners.nounit.snippet.Snippets; 34 import net.firstpartners.nounit.utility.NoUnitException; 35 36 import org.jdom.output.XMLOutputter; 37 38 39 42 public class Processor implements IProcessor { 43 44 49 public CommandPackage transform(CommandPackage inCommandPackage) 50 throws NoUnitException{ 51 52 try{ 53 54 55 CommandValueChecker checkArgs = new CommandValueChecker(); 57 checkArgs.checkValues(inCommandPackage); 58 59 ByteCodeProjectSnippetFactory myFactory 61 = new ByteCodeProjectSnippetFactory(inCommandPackage.getString( 62 CommandPackage.START_DIR)); 63 64 Snippets projectInfo= myFactory.getSnippets(); 65 66 67 String outDir = 69 inCommandPackage.getString( CommandPackage.OUTPUT_DIR ); 70 File destination = new File ( outDir, SystemValues.XML_OUTPUT_NAME ); 71 72 if ( destination.exists() ) { 74 destination.delete(); 75 } 76 77 FileOutputStream output = new FileOutputStream (destination); 79 80 XMLOutputter fmt = new XMLOutputter(" ", true); 82 fmt.output( projectInfo.getFirstItem().getNodes(), output ); 83 84 IReport thisReport = ReportPicker.getReportMaker(inCommandPackage); 86 thisReport.makeReport(inCommandPackage); 87 88 inCommandPackage.addValue(CommandPackage.USER_MESSAGE, 90 "Transformation Successful"); 91 92 93 } catch (java.io.IOException ioe) { 94 95 throw new NoUnitException(ioe,"IO Error"); 96 97 } catch (javax.xml.transform.TransformerException te) { 98 99 throw new NoUnitException(te,"Transformation Error"); 100 } 101 102 return inCommandPackage; 103 } 104 105 } 106 | Popular Tags |