X-Git-Url: http://jaekl.net/gitweb/?p=cfb.git;a=blobdiff_plain;f=prod%2Fnet%2Fjaekl%2Fcfb%2Fanalyze%2FAnalyzer.java;h=d1aa115e9d6ab3418c1f20979ad3fa446d7737b8;hp=715cae91544173511b0d256fae0ed9fd0a634b27;hb=2769cf82ccae57ee3716aecc9bd694be1f115d92;hpb=08a530ef53cc4756f5e632b69c78830872ebd9f4 diff --git a/prod/net/jaekl/cfb/analyze/Analyzer.java b/prod/net/jaekl/cfb/analyze/Analyzer.java index 715cae9..d1aa115 100644 --- a/prod/net/jaekl/cfb/analyze/Analyzer.java +++ b/prod/net/jaekl/cfb/analyze/Analyzer.java @@ -1,24 +1,33 @@ package net.jaekl.cfb.analyze; +// Copyright (C) 2015 Christian Jaekl + import java.io.File; import java.io.IOException; import java.io.PrintWriter; import java.text.MessageFormat; +import java.util.Date; import java.util.Locale; import java.util.Locale.Category; import net.jaekl.cfb.CfbBundle; import net.jaekl.cfb.util.Command; +import net.jaekl.qd.xml.XmlParseException; + +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; public class Analyzer { - File m_findbugsDir; + MessageMap m_msgMap; - public Analyzer(File findbugsDir) { - m_findbugsDir = findbugsDir; + public Analyzer(MessageMap msgMap) { + m_msgMap = msgMap; } - public Analysis analyze(PrintWriter pw, File workDir, File fbp) throws IOException { - Analysis result = new Analysis(); + public Analysis analyze(PrintWriter pw, File workDir, File fbp, String projName, String buildNumber) + throws IOException, XmlParseException, SAXException + { + Analysis result = new Analysis(projName, buildNumber); File fbOutput = outputWorkFile(workDir, fbp); @@ -26,6 +35,8 @@ public class Analyzer { pw.println(cmdLine); pw.flush(); Command.Result fbResult = new Command().exec(cmdLine); + pw.println("==> " + fbResult.getRetCode()); + pw.flush(); if (0 != fbResult.getRetCode()) { // Our attempt to execute FindBugs failed. // Report the error and return null. @@ -39,8 +50,9 @@ public class Analyzer { return null; } - result = parseFbOutput(fbOutput); - + result.setEnd(new Date()); + result.parse(new InputSource(fbOutput.getAbsolutePath())); + // result.dump(pw); return result; } @@ -56,7 +68,7 @@ public class Analyzer { StringBuilder sb = new StringBuilder(); - sb.append(m_findbugsDir.getAbsolutePath()) + sb.append(m_msgMap.getFindBugsDir().getAbsolutePath()) .append(File.separator) .append("bin") .append(File.separator) @@ -89,11 +101,4 @@ public class Analyzer { return new File(workPath + File.separator + projName + ".xml"); } - - // Parse the output.xml that resulted from a FindBugs run, - // and store its findings into an Analysis object. - Analysis parseFbOutput(File fbOutput) - { - return null; - } }