Partial implemenation of load-Analysis code.
[cfb.git] / prod / net / jaekl / cfb / analyze / Analysis.java
index e8a938aa33c33ea710f7149da80c1078fd897d47..66c0b8850cea2102f5502295bd4ac8219f00d983 100644 (file)
@@ -1,5 +1,64 @@
 package net.jaekl.cfb.analyze;
 
+// Copyright (C) 2015 Christian Jaekl
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Date;
+
+import net.jaekl.cfb.xml.BugCollection;
+import net.jaekl.qd.xml.ParseErrorHandler;
+import net.jaekl.qd.xml.ParseHandler;
+
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+import org.xml.sax.helpers.XMLReaderFactory;
+
 public class Analysis {
+       long m_id;
+       BugCollection m_bugCollection;
+       String m_buildNumber;
+       Date m_start;   // Date/time when analysis was started
+       Date m_end;
+       
+       public Analysis(String buildNumber) {
+               m_id = (-1);
+               m_bugCollection = null;
+               m_buildNumber = buildNumber;
+               m_start = new Date();
+               m_end = null;
+       }
+       
+       public BugCollection getBugCollection() { return m_bugCollection; }
+       public long getId() { return m_id; }
+       public String getBuildNumber() { return m_buildNumber; }
+       public Date getStart() { return m_start; }
+       public Date getEnd() { return m_end; }  // the end time (when FindBugs was done analyzing)
 
+       public void setBugCollection(BugCollection bugs) { m_bugCollection = bugs; }
+       public void setId(long id) { m_id = id; }
+       public void setStart(Date start) { m_start = start; }
+       public void setEnd(Date date) { m_end = date; }
+       
+       public void parse(InputSource xml) throws FileNotFoundException, IOException, SAXException 
+       {
+               m_bugCollection = new BugCollection();
+               
+           XMLReader reader = XMLReaderFactory.createXMLReader();
+           ParseHandler ph = new ParseHandler(m_bugCollection);
+           ParseErrorHandler peh = new ParseErrorHandler();
+           reader.setContentHandler(ph);
+           reader.setErrorHandler(peh);
+           reader.parse(xml);
+       }
+       
+       
+       public void dump(PrintWriter pw)
+       {
+               if (null != m_bugCollection) {
+                       m_bugCollection.dump(pw, 2);
+               }
+       }
 }