private static Set<String> getAllParserNames() { Set<String> parsers = new HashSet<String>(); for (WarningsParser parser : getAllParsers()) { parsers.add(parser.getName()); } return parsers; }
/** * Returns a list of parsers that match the specified names. Note that the mapping of names to * parsers is one to many. * * @param parserNames the parser names * @return a list of parsers, might be modified by the receiver */ public static List<WarningsParser> getParsers(final Collection<String> parserNames) { List<WarningsParser> actualParsers = new ArrayList<WarningsParser>(); for (String name : parserNames) { for (WarningsParser warningsParser : getAllParsers()) { if (warningsParser.getName().equals(name)) { actualParsers.add(warningsParser); } } } return actualParsers; }
/** * 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); }