Ejemplo n.º 1
0
 private void parse(SMHierarchicCursor rootCursor) throws XMLStreamException {
   try {
     streamHandler.stream(rootCursor);
   } finally {
     rootCursor.getStreamReader().closeCompletely();
   }
 }
 /**
  * Parses a processed violation file.
  *
  * @param file the file to parse
  */
 public void parse(File file) {
   SMInputFactory inputFactory = initStax();
   FileInputStream fileInputStream = null;
   try {
     fileInputStream = new FileInputStream(file);
     SMHierarchicCursor cursor =
         inputFactory.rootElementCursor(new InputStreamReader(fileInputStream, getEncoding()));
     SMInputCursor mainCursor = cursor.advance().childElementCursor();
     parseStyleCopViolationsBloc(mainCursor);
     cursor.getStreamReader().closeCompletely();
   } catch (XMLStreamException e) {
     throw new SonarException(
         "Error while reading StyleCop result file: " + file.getAbsolutePath(), e);
   } catch (FileNotFoundException e) {
     throw new SonarException("Cannot find StyleCop result file: " + file.getAbsolutePath(), e);
   } finally {
     IOUtils.closeQuietly(fileInputStream);
   }
 }