package net.jaekl.cfb.analyze;
-public class Analysis {
+// Copyright (C) 2015 Christian Jaekl
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.PrintWriter;
+
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+import org.xml.sax.helpers.XMLReaderFactory;
+import net.jaekl.cfb.xml.BugCollection;
+import net.jaekl.qd.util.InputStreamWrapper;
+import net.jaekl.qd.xml.ParseErrorHandler;
+import net.jaekl.qd.xml.ParseHandler;
+
+public class Analysis {
+ BugCollection m_bugCollection;
+
+ public Analysis() {
+ m_bugCollection = null;
+ }
+
+ public BugCollection getBugCollection() { return m_bugCollection; }
+
+ public void parse(File xml) throws FileNotFoundException, IOException, SAXException
+ {
+ m_bugCollection = new BugCollection();
+
+ try (InputStreamWrapper isw = new InputStreamWrapper(new FileInputStream(xml)))
+ {
+ XMLReader reader = XMLReaderFactory.createXMLReader();
+ ParseHandler ph = new ParseHandler(m_bugCollection);
+ ParseErrorHandler peh = new ParseErrorHandler();
+ reader.setContentHandler(ph);
+ reader.setErrorHandler(peh);
+ reader.parse(new InputSource(isw));
+ }
+ }
+
+ public void dump(PrintWriter pw)
+ {
+ if (null != m_bugCollection) {
+ m_bugCollection.dump(pw, 2);
+ }
+ }
}