Improve XML parsing to handle attributes as well.
[cfb.git] / prod / net / jaekl / cfb / analyze / Analyzer.java
index 715cae91544173511b0d256fae0ed9fd0a634b27..9a8d7a64c4ea6f7a4069dfb3b396e1ddd65f382f 100644 (file)
@@ -1,5 +1,7 @@
 package net.jaekl.cfb.analyze;
 
+// Copyright (C) 2015 Christian Jaekl
+
 import java.io.File;
 import java.io.IOException;
 import java.io.PrintWriter;
@@ -7,8 +9,11 @@ import java.text.MessageFormat;
 import java.util.Locale;
 import java.util.Locale.Category;
 
+import org.xml.sax.SAXException;
+
 import net.jaekl.cfb.CfbBundle;
 import net.jaekl.cfb.util.Command;
+import net.jaekl.qd.xml.XmlParseException;
 
 public class Analyzer {
        File m_findbugsDir;
@@ -17,7 +22,7 @@ public class Analyzer {
                m_findbugsDir = findbugsDir;
        }
        
-       public Analysis analyze(PrintWriter pw, File workDir, File fbp) throws IOException {
+       public Analysis analyze(PrintWriter pw, File workDir, File fbp) throws IOException, XmlParseException {
                Analysis result = new Analysis();
        
                File fbOutput = outputWorkFile(workDir, fbp);
@@ -40,7 +45,7 @@ public class Analyzer {
                }
                
                result = parseFbOutput(fbOutput);
-               
+               result.dump(pw);                        
                return result;
        }
        
@@ -92,8 +97,14 @@ public class Analyzer {
        
        // Parse the output.xml that resulted from a FindBugs run,
        // and store its findings into an Analysis object.
-       Analysis parseFbOutput(File fbOutput) 
+       Analysis parseFbOutput(File fbOutput) throws XmlParseException 
        {
-               return null;
+               Analysis result = new Analysis();
+               try {
+                       result.parse(fbOutput);
+               } catch (IOException | SAXException exc) {
+                       throw new XmlParseException(exc);
+               }
+               return result;
        }
 }