/** * Iterates over the available parsers and parses the specified file with each parser. Returns all * found warnings. * * @param file the input stream * @return all found warnings * @throws IOException Signals that an I/O exception has occurred. */ public Set<FileAnnotation> parse(final InputStream file) throws IOException { try { Set<FileAnnotation> allAnnotations = Sets.newHashSet(); for (WarningsParser parser : parsers) { allAnnotations.addAll(parser.parse(createReader(file))); } return applyExcludeFilter(allAnnotations); } finally { IOUtils.closeQuietly(file); } }
/** * Iterates over the available parsers and parses the specified file with each parser. Returns all * found warnings. * * @param file the input stream * @param logger the logger to write to * @return all found warnings * @throws IOException Signals that an I/O exception has occurred. */ public Collection<FileAnnotation> parse(final File file, final PluginLogger logger) throws IOException { Set<FileAnnotation> allAnnotations = Sets.newHashSet(); for (WarningsParser parser : parsers) { Reader input = null; try { input = createReader(file); Collection<FileAnnotation> warnings = parser.parse(input); logger.log(String.format("%s : Found %d warnings.", parser.getName(), warnings.size())); allAnnotations.addAll(warnings); } finally { IOUtils.closeQuietly(input); } } return applyExcludeFilter(allAnnotations); }