1 package net.jaekl.cfb.analyze;
3 // Copyright (C) 2015 Christian Jaekl
5 import java.io.FileNotFoundException;
6 import java.io.IOException;
7 import java.io.PrintWriter;
10 import net.jaekl.cfb.xml.BugCollection;
11 import net.jaekl.qd.xml.ParseErrorHandler;
12 import net.jaekl.qd.xml.ParseHandler;
14 import org.xml.sax.InputSource;
15 import org.xml.sax.SAXException;
16 import org.xml.sax.XMLReader;
17 import org.xml.sax.helpers.XMLReaderFactory;
19 public class Analysis {
21 BugCollection m_bugCollection;
24 long m_start; // Date.getTime() when analysis was started
27 public Analysis(String projectName, String buildNumber) {
29 m_bugCollection = null;
30 m_projectName = projectName;
31 m_buildNumber = buildNumber;
32 m_start = new Date().getTime();
34 m_bugCollection = new BugCollection();
37 public BugCollection getBugCollection() { return m_bugCollection; }
38 public long getId() { return m_id; }
39 public String getProjectName() { return m_projectName; }
40 public String getBuildNumber() { return m_buildNumber; }
41 public Date getStart() { return new Date(m_start); }
42 public Date getEnd() { return (0 == m_end ? null : new Date(m_end)); } // the end time (when FindBugs was done analyzing)
44 public void setBugCollection(BugCollection bugs) { m_bugCollection = bugs; }
45 public void setId(long id) { m_id = id; }
46 public void setStart(Date start) { m_start = start.getTime(); }
47 public void setEnd(Date date) { m_end = date.getTime(); }
49 public void parse(InputSource xml) throws FileNotFoundException, IOException, SAXException
51 m_bugCollection = new BugCollection();
53 XMLReader reader = XMLReaderFactory.createXMLReader();
54 ParseHandler ph = new ParseHandler(m_bugCollection);
55 ParseErrorHandler peh = new ParseErrorHandler();
56 reader.setContentHandler(ph);
57 reader.setErrorHandler(peh);
62 public void dump(PrintWriter pw)
64 if (null != m_bugCollection) {
65 m_bugCollection.dump(pw, 2);