/**
   * Pre-parses a file for some information not available from the FindBugs parser. Creates a
   * mapping of FindBugs warnings to messages. A bug is represented by its unique hash code. Also
   * obtains original categories for bug types.
   *
   * @param file the FindBugs XML file
   * @return the map of warning messages
   * @throws SAXException if the file contains no valid XML
   * @throws IOException signals that an I/O exception has occurred.
   */
  List<XmlBugInstance> preParse(final InputStream file) throws SAXException, IOException {
    Digester digester = new Digester();
    digester.setValidating(false);
    digester.setClassLoader(FindBugsParser.class.getClassLoader());

    String rootXPath = "BugCollection/BugInstance";
    digester.addObjectCreate(rootXPath, XmlBugInstance.class);
    digester.addSetProperties(rootXPath);

    String fileXPath = rootXPath + "/LongMessage";
    digester.addCallMethod(fileXPath, "setMessage", 0);

    digester.addSetNext(rootXPath, "add", Object.class.getName());
    ArrayList<XmlBugInstance> bugs = new ArrayList<XmlBugInstance>();
    digester.push(bugs);
    digester.parse(file);

    return bugs;
  }