/** 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(); } }
/** 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(); } }