Add code to load bug categories and patterns from the FindBugs messages.xml file.
[cfb.git] / prod / net / jaekl / cfb / analyze / Analyzer.java
index 5e72fe0499db0b7d2f50c3b67ec09f13eb8b7da8..03aeb1c6a4db718198e2eca9da9b9538829eab39 100644 (file)
@@ -17,14 +17,15 @@ import net.jaekl.cfb.util.Command;
 import net.jaekl.qd.xml.XmlParseException;
 
 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, XmlParseException {
-               Analysis result = new Analysis();
+       public Analysis analyze(PrintWriter pw, File workDir, File fbp, String buildNumber) throws IOException, XmlParseException, SAXException 
+       {
+               Analysis result = new Analysis(buildNumber);
        
                File fbOutput = outputWorkFile(workDir, fbp);
                
@@ -45,7 +46,7 @@ public class Analyzer {
                        return null;
                }
                
-               result = parseFbOutput(new InputSource(fbOutput.getAbsolutePath()));
+               result.parse(new InputSource(fbOutput.getAbsolutePath()));
                result.dump(pw);                        
                return result;
        }
@@ -62,7 +63,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)
@@ -95,17 +96,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(InputSource fbOutput) throws XmlParseException 
-       {
-               Analysis result = new Analysis();
-               try {
-                       result.parse(fbOutput);
-               } catch (IOException | SAXException exc) {
-                       throw new XmlParseException(exc);
-               }
-               return result;
-       }
 }