/** * Returns an unmodifiable map instance containing the custom messages * for this configuration. * @return unmodifiable map containing custom messages */ protected Map<String, String> getCustomMessages() { return getConfiguration().getMessages(); }
/** * Returns the message bundle name resource bundle that contains the messages * used by this module. * <p> * The default implementation expects the resource files to be named * messages.properties, messages_de.properties, etc. The file must * be placed in the same package as the module implementation. * </p> * <p> * Example: If you write com/foo/MyCoolCheck, create resource files * com/foo/messages.properties, com/foo/messages_de.properties, etc. * </p> * * @return name of a resource bundle that contains the messages * used by this module. */ protected String getMessageBundle() { final String className = getClass().getName(); return getMessageBundle(className); }
/** Perform processing at the end of a set of lines. */ private void finish() { if (currentMatches < options.getMinimum()) { if (options.getMessage().isEmpty()) { options.getReporter().log(1, MSG_REGEXP_MINIMUM, options.getMinimum(), options.getFormat()); } else { options.getReporter().log(1, options.getMessage()); } } }
/** Perform processing at the end of a set of lines. */ private void finish() { if (currentMatches < options.getMinimum()) { if (options.getMessage().isEmpty()) { options.getReporter().log(1, MSG_REGEXP_MINIMUM, options.getMinimum(), options.getFormat()); } else { options.getReporter().log(1, options.getMessage()); } } }
/** * Returns an unmodifiable map instance containing the custom messages * for this configuration. * @return unmodifiable map containing custom messages */ protected Map<String, String> getCustomMessages() { return getConfiguration().getMessages(); }
/** * Returns the message bundle name resource bundle that contains the messages * used by this module. * <p> * The default implementation expects the resource files to be named * messages.properties, messages_de.properties, etc. The file must * be placed in the same package as the module implementation. * </p> * <p> * Example: If you write com/foo/MyCoolCheck, create resource files * com/foo/messages.properties, com/foo/messages_de.properties, etc. * </p> * * @return name of a resource bundle that contains the messages * used by this module. */ protected String getMessageBundle() { final String className = getClass().getName(); return getMessageBundle(className); }
/** Method that finds the matches. */ private void findMatch() { try { boolean foundMatch = matcher.find(); while (foundMatch) { currentMatches++; if (currentMatches > options.getMaximum()) { final LineColumn start = text.lineColumn(matcher.start()); if (options.getMessage().isEmpty()) { options.getReporter().log(start.getLine(), MSG_REGEXP_EXCEEDED, matcher.pattern().toString()); } else { options.getReporter() .log(start.getLine(), options.getMessage()); } } foundMatch = matcher.find(); } } // see http://bugs.java.com/bugdatabase/view_bug.do?bug_id=6337993 et al. catch (StackOverflowError ignored) { // OK http://blog.igorminar.com/2008/05/catching-stackoverflowerror-and-bug-in.html // http://programmers.stackexchange.com/questions/ // 209099/is-it-ever-okay-to-catch-stackoverflowerror-in-java options.getReporter().log(1, MSG_STACKOVERFLOW, matcher.pattern().toString()); } }
/** * Processes an entire text file looking for matches. * @param fileText the text to process */ public void processLines(FileText fileText) { text = new FileText(fileText); resetState(); final String format = options.getFormat(); if (format == null || format.isEmpty()) { options.getReporter().log(1, MSG_EMPTY); } else { matcher = options.getPattern().matcher(fileText.getFullText()); findMatch(); finish(); } }
/** Perform processing at the end of a set of lines. */ private void finish() { if (currentMatches < options.getMinimum()) { if (options.getMessage().isEmpty()) { options.getReporter().log(1, MSG_REGEXP_MINIMUM, options.getMinimum(), options.getFormat()); } else { options.getReporter().log(1, options.getMessage()); } } }
/** Perform processing at the end of a set of lines. */ private void finish() { if (currentMatches < options.getMinimum()) { if (options.getMessage().isEmpty()) { options.getReporter().log(1, MSG_REGEXP_MINIMUM, options.getMinimum(), options.getFormat()); } else { options.getReporter().log(1, options.getMessage()); } } }
/** Method that finds the matches. */ private void findMatch() { try { boolean foundMatch = matcher.find(); while (foundMatch) { currentMatches++; if (currentMatches > options.getMaximum()) { final LineColumn start = text.lineColumn(matcher.start()); if (options.getMessage().isEmpty()) { options.getReporter().log(start.getLine(), MSG_REGEXP_EXCEEDED, matcher.pattern().toString()); } else { options.getReporter() .log(start.getLine(), options.getMessage()); } } foundMatch = matcher.find(); } } // see http://bugs.java.com/bugdatabase/view_bug.do?bug_id=6337993 et al. catch (StackOverflowError ignored) { // OK http://blog.igorminar.com/2008/05/catching-stackoverflowerror-and-bug-in.html // http://programmers.stackexchange.com/questions/ // 209099/is-it-ever-okay-to-catch-stackoverflowerror-in-java options.getReporter().log(1, MSG_STACKOVERFLOW, matcher.pattern().toString()); } }
/** * Processes an entire text file looking for matches. * @param fileText the text to process */ public void processLines(FileText fileText) { text = new FileText(fileText); resetState(); final String format = options.getFormat(); if (format == null || format.isEmpty()) { options.getReporter().log(1, MSG_EMPTY); } else { matcher = options.getPattern().matcher(fileText.getFullText()); findMatch(); finish(); } }