예제 #1
0
  /**
   * Filters the report XML file using the JDK XSL processor.
   *
   * @throws TransformerException if the transformation fails.
   * @throws IOException if an io operation fails.
   */
  public void filter() throws TransformerException, IOException {
    logger.log(Level.FINE, "Filtering jcoderz-report.xml files...");
    for (final File filterFile : mFilters) {
      logger.log(Level.FINE, "Filter: " + filterFile);
      final TransformerFactory tFactory = TransformerFactory.newInstance();

      final Transformer transformer = tFactory.newTransformer(new StreamSource(filterFile));

      final File tempOutputFile = new File(mOutFile.getCanonicalPath() + ".tmp");
      FileUtils.createNewFile(tempOutputFile);

      final FileOutputStream out = new FileOutputStream(tempOutputFile);
      transformer.transform(new StreamSource(mOutFile), new StreamResult(out));
      IoUtil.close(out);
      FileUtils.copyFile(tempOutputFile, mOutFile);
      FileUtils.delete(tempOutputFile);
    }
  }
예제 #2
0
 /**
  * Sets the out file.
  *
  * @param outFile the new out file
  * @throws IOException Signals that an I/O exception has occurred.
  */
 public void setOutFile(File outFile) throws IOException {
   if (mOutFile != null) {
     throw new ArgumentMalformedException(
         "outFile", outFile, "Out File already set to '" + mOutFile + "'.");
   }
   mOutFile = outFile;
   if (mOutFile.isDirectory()) {
     FileUtils.mkdirs(mOutFile);
     mOutFile = new File(mOutFile, ReportNormalizer.JCODERZ_REPORT_XML).getCanonicalFile();
   } else {
     mOutFile = mOutFile.getCanonicalFile();
   }
 }