Пример #1
0
  private void parseDataSource(String file) throws Exception {
    Digester digester = new Digester();
    digester.setValidating(false);
    digester.push(this);
    digester.addCallMethod("datasources/datasource", "addDataSource", 6);

    digester.addCallParam("datasources/datasource/name", 0);
    digester.addCallParam("datasources/datasource/driver", 1);
    digester.addCallParam("datasources/datasource/url", 2);
    digester.addCallParam("datasources/datasource/username", 3);
    digester.addCallParam("datasources/datasource/password", 4);
    digester.addCallParam("datasources/datasource/internallogon", 5);
    digester.parse(new File(file));
  }
  /**
   * 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;
  }