@Test public void testRecognizePatterns_non_valid() throws Exception { assertEquals(0, PatternProvider.recommendPatterns("no_valid_pattern").size()); }
public static List<String[]> recommendPatterns(String fileName) { fileName = replaceColon(fileName); List<String[]> patternCombinations = new ArrayList<String[]>(); for (String dateString : DATE_PATTERNS) { dateString = replaceColon(dateString); final Pattern datePattern = convertDateStringToPattern(dateString); Matcher matcher = datePattern.matcher(fileName); if (matcher.matches()) { TimeStampExtractor timeStampExtractor = new TimeStampExtractor(dateString, FILENAME_PATTERNS[0]); try { timeStampExtractor.extractTimeStamps(fileName); patternCombinations.add(new String[]{insertColon(dateString), FILENAME_PATTERNS[0]}); try { timeStampExtractor = new TimeStampExtractor(insertColon(dateString), FILENAME_PATTERNS[1]); timeStampExtractor.extractTimeStamps(fileName); patternCombinations.add(new String[]{dateString, FILENAME_PATTERNS[1]}); } catch (ValidationException e) { } } catch (ValidationException e) { } } } return patternCombinations; }
PatternProvider { public static List<String[]> recommendPatterns(String fileName) { fileName = replaceColon(fileName); List<String[]> patternCombinations = new ArrayList<String[]>(); for (String dateString : DATE_PATTERNS) { dateString = replaceColon(dateString); final Pattern datePattern = convertDateStringToPattern(dateString); Matcher matcher = datePattern.matcher(fileName); if (matcher.matches()) { TimeStampExtractor timeStampExtractor = new TimeStampExtractor(dateString, FILENAME_PATTERNS[0]); try { timeStampExtractor.extractTimeStamps(fileName); patternCombinations.add(new String[]{insertColon(dateString), FILENAME_PATTERNS[0]}); try { timeStampExtractor = new TimeStampExtractor(insertColon(dateString), FILENAME_PATTERNS[1]); timeStampExtractor.extractTimeStamps(fileName); patternCombinations.add(new String[]{dateString, FILENAME_PATTERNS[1]}); } catch (ValidationException e) { } } catch (ValidationException e) { } } } return patternCombinations; } }
PatternProvider { public static List<String[]> recommendPatterns(String fileName) { fileName = replaceColon(fileName); List<String[]> patternCombinations = new ArrayList<String[]>(); for (String dateString : DATE_PATTERNS) { dateString = replaceColon(dateString); final Pattern datePattern = convertDateStringToPattern(dateString); Matcher matcher = datePattern.matcher(fileName); if (matcher.matches()) { TimeStampExtractor timeStampExtractor = new TimeStampExtractor(dateString, FILENAME_PATTERNS[0]); try { timeStampExtractor.extractTimeStamps(fileName); patternCombinations.add(new String[]{insertColon(dateString), FILENAME_PATTERNS[0]}); try { timeStampExtractor = new TimeStampExtractor(insertColon(dateString), FILENAME_PATTERNS[1]); timeStampExtractor.extractTimeStamps(fileName); patternCombinations.add(new String[]{dateString, FILENAME_PATTERNS[1]}); } catch (ValidationException e) { } } catch (ValidationException e) { } } } return patternCombinations; }  }
PatternProvider { public static List<String[]> recommendPatterns(String fileName) { fileName = replaceColon(fileName); List<String[]> patternCombinations = new ArrayList<String[]>(); for (String dateString : DATE_PATTERNS) { dateString = replaceColon(dateString); final Pattern datePattern = convertDateStringToPattern(dateString); Matcher matcher = datePattern.matcher(fileName); if (matcher.matches()) { TimeStampExtractor timeStampExtractor = new TimeStampExtractor(dateString, FILENAME_PATTERNS[0]); try { timeStampExtractor.extractTimeStamps(fileName); patternCombinations.add(new String[]{insertColon(dateString), FILENAME_PATTERNS[0]}); try { timeStampExtractor = new TimeStampExtractor(insertColon(dateString), FILENAME_PATTERNS[1]); timeStampExtractor.extractTimeStamps(fileName); patternCombinations.add(new String[]{dateString, FILENAME_PATTERNS[1]}); } catch (ValidationException e) { } } catch (ValidationException e) { } } } return patternCombinations; }  static List<String[]> recommendPatterns(String fileName); }
PatternProvider { public static List<String[]> recommendPatterns(String fileName) { fileName = replaceColon(fileName); List<String[]> patternCombinations = new ArrayList<String[]>(); for (String dateString : DATE_PATTERNS) { dateString = replaceColon(dateString); final Pattern datePattern = convertDateStringToPattern(dateString); Matcher matcher = datePattern.matcher(fileName); if (matcher.matches()) { TimeStampExtractor timeStampExtractor = new TimeStampExtractor(dateString, FILENAME_PATTERNS[0]); try { timeStampExtractor.extractTimeStamps(fileName); patternCombinations.add(new String[]{insertColon(dateString), FILENAME_PATTERNS[0]}); try { timeStampExtractor = new TimeStampExtractor(insertColon(dateString), FILENAME_PATTERNS[1]); timeStampExtractor.extractTimeStamps(fileName); patternCombinations.add(new String[]{dateString, FILENAME_PATTERNS[1]}); } catch (ValidationException e) { } } catch (ValidationException e) { } } } return patternCombinations; }  static List<String[]> recommendPatterns(String fileName); static final String[] DATE_PATTERNS; static final String[] FILENAME_PATTERNS; }