@Test public void testDateMatching() throws Exception { List<Match> actualMatches = new DateMatcher().execute(password); assertMatches(message, Pattern.Date, new ExpectedMatch[]{expectedMatch}, actualMatches); }
List<Integer> rest = possibleYearSplitRef.getValue(); if (DATE_MIN_YEAR <= y && y <= DATE_MAX_YEAR) { Dm dm = mapIntsToDm(rest); if (dm != null) { return new Dmy(dm.day, dm.month, y); int y = possibleYearSplitRef.getKey(); List<Integer> rest = possibleYearSplitRef.getValue(); Dm dm = mapIntsToDm(rest); if (dm != null) { y = twoToFourDigitYear(y); return new Dmy(dm.day, dm.month, y);
ints.add(Integer.parseInt(token.substring(k, l))); ints.add(Integer.parseInt(token.substring(l))); Dmy dmy = mapIntsToDmy(ints); if (dmy != null) { candidates.add(dmy); int minDistance = metric(candidates.get(0)); for (Dmy candidate: candidates.subList(1, candidates.size())) { int distance = metric(candidate); if (distance < minDistance) { bestCandidate = candidate; ints.add(Integer.parseInt(rxMatch.group(3))); ints.add(Integer.parseInt(rxMatch.group(4))); Dmy dmy = mapIntsToDmy(ints); if (dmy == null) continue; matches.add(MatchFactory.createDateMatch(i, j, token, rxMatch.group(2), dmy.year, dmy.month, dmy.day)); return this.sorted(targetMatches);
@Override public List<Match> execute(String password) { List<Match> matches = new ArrayList<>(); List<Matcher> matchers = new ArrayList<>(); matchers.add(new DictionaryMatcher(dictionaries)); matchers.add(new ReverseDictionaryMatcher(dictionaries)); matchers.add(new L33tMatcher(dictionaries)); matchers.add(new SpatialMatcher()); matchers.add(new RepeatMatcher()); matchers.add(new SequenceMatcher()); matchers.add(new RegexMatcher()); matchers.add(new DateMatcher()); for (Matcher matcher: matchers) matches.addAll(matcher.execute(password)); return this.sorted(matches); } }
ints.add(Integer.parseInt(token.substring(k, l))); ints.add(Integer.parseInt(token.substring(l))); Dmy dmy = mapIntsToDmy(ints); if (dmy != null) { candidates.add(dmy); int minDistance = metric(candidates.get(0)); for (Dmy candidate: candidates.subList(1, candidates.size())) { int distance = metric(candidate); if (distance < minDistance) { bestCandidate = candidate; ints.add(Integer.parseInt(rxMatch.group(3))); ints.add(Integer.parseInt(rxMatch.group(4))); Dmy dmy = mapIntsToDmy(ints); if (dmy == null) continue; matches.add(MatchFactory.createDateMatch(i, j, token, rxMatch.group(2), dmy.year, dmy.month, dmy.day)); return this.sorted(targetMatches);
@Override public List<Match> execute(String password) { List<Match> matches = new ArrayList<>(); List<Matcher> matchers = new ArrayList<>(); matchers.add(new DictionaryMatcher(dictionaries)); matchers.add(new ReverseDictionaryMatcher(dictionaries)); matchers.add(new L33tMatcher(dictionaries)); matchers.add(new SpatialMatcher()); matchers.add(new RepeatMatcher()); matchers.add(new SequenceMatcher()); matchers.add(new RegexMatcher()); matchers.add(new DateMatcher()); for (Matcher matcher: matchers) matches.addAll(matcher.execute(password)); return this.sorted(matches); } }
List<Integer> rest = possibleYearSplitRef.getValue(); if (DATE_MIN_YEAR <= y && y <= DATE_MAX_YEAR) { Dm dm = mapIntsToDm(rest); if (dm != null) { return new Dmy(dm.day, dm.month, y); int y = possibleYearSplitRef.getKey(); List<Integer> rest = possibleYearSplitRef.getValue(); Dm dm = mapIntsToDm(rest); if (dm != null) { y = twoToFourDigitYear(y); return new Dmy(dm.day, dm.month, y);