@Test public void testGetHouseNumber() { assertExpectedMatch(FindAddress.matchHouseNumber("4", 0), "4"); assertExpectedMatch(FindAddress.matchHouseNumber(" 4", 1), "4"); assertExpectedMatch(FindAddress.matchHouseNumber(",4", 1), "4"); Assert.assertNull(FindAddress.matchHouseNumber("x4", 1)); assertExpectedMatch(FindAddress.matchHouseNumber("4,5", 0), "4"); Assert.assertNull(FindAddress.matchHouseNumber("4?", 0)); Assert.assertNull(FindAddress.matchHouseNumber("4:", 0)); assertExpectedMatch(FindAddress.matchHouseNumber("\"4\"", 1), "4"); assertExpectedMatch(FindAddress.matchHouseNumber("'4'", 1), "4"); assertExpectedMatch(FindAddress.matchHouseNumber("4 my house", 0), "4"); assertExpectedMatch(FindAddress.matchHouseNumber("one", 0), "one"); Assert.assertNull(FindAddress.matchHouseNumber("oneth", 0)); assertExpectedMatch(FindAddress.matchHouseNumber("1A", 0), "1A"); Assert.assertNull(FindAddress.matchHouseNumber("1AA", 0)); assertExpectedMatch(FindAddress.matchHouseNumber("1st", 0), "1st"); assertExpectedMatch(FindAddress.matchHouseNumber("1ST", 0), "1ST"); assertExpectedMatch(FindAddress.matchHouseNumber("11th", 0), "11th"); assertExpectedMatch(FindAddress.matchHouseNumber("21st", 0), "21st"); assertExpectedMatch(FindAddress.matchHouseNumber("2nd", 0), "2nd"); assertExpectedMatch(FindAddress.matchHouseNumber("12th", 0), "12th"); assertExpectedMatch(FindAddress.matchHouseNumber("22nd", 0), "22nd"); assertExpectedMatch(FindAddress.matchHouseNumber("3rd", 0), "3rd"); assertExpectedMatch(FindAddress.matchHouseNumber("13th", 0), "13th"); assertExpectedMatch(FindAddress.matchHouseNumber("23rd", 0), "23rd"); Assert.assertNull(FindAddress.matchHouseNumber("11st", 0)); Assert.assertNull(FindAddress.matchHouseNumber("21th", 0)); Assert.assertNull(FindAddress.matchHouseNumber("1nd", 0)); assertExpectedMatch(FindAddress.matchHouseNumber("111th", 0), "111th"); assertExpectedMatch(FindAddress.matchHouseNumber("011th", 0), "011th"); Assert.assertNull(FindAddress.matchHouseNumber("211st", 0)); assertExpectedMatch(FindAddress.matchHouseNumber("1-201", 0), "1-201"); assertExpectedMatch(FindAddress.matchHouseNumber("1-one", 0), "1-one"); Assert.assertNull(FindAddress.matchHouseNumber("1- ", 0)); Assert.assertNull(FindAddress.matchHouseNumber("1-word", 0)); assertExpectedMatch(FindAddress.matchHouseNumber("1-1st", 0), "1-1st"); assertExpectedMatch(FindAddress.matchHouseNumber("12345", 0), "12345"); Assert.assertNull(FindAddress.matchHouseNumber("123456", 0)); Assert.assertNull(FindAddress.matchHouseNumber("123-456", 0)); }
@VisibleForTesting public static MatchResult matchHouseNumber(String content, int offset) { if (offset > 0 && HOUSE_PRE_DELIM.indexOf(content.charAt(offset - 1)) == -1) return null; Matcher matcher = sHouseNumberRe.matcher(content).region(offset, content.length()); if (matcher.lookingAt()) { MatchResult matchResult = matcher.toMatchResult(); if (checkHouseNumber(matchResult.group(0))) return matchResult; } return null; }
FindAddress { @VisibleForTesting public static MatchResult matchHouseNumber(String content, int offset) { if (offset > 0 && HOUSE_PRE_DELIM.indexOf(content.charAt(offset - 1)) == -1) return null; Matcher matcher = sHouseNumberRe.matcher(content).region(offset, content.length()); if (matcher.lookingAt()) { MatchResult matchResult = matcher.toMatchResult(); if (checkHouseNumber(matchResult.group(0))) return matchResult; } return null; } }
FindAddress { @VisibleForTesting public static MatchResult matchHouseNumber(String content, int offset) { if (offset > 0 && HOUSE_PRE_DELIM.indexOf(content.charAt(offset - 1)) == -1) return null; Matcher matcher = sHouseNumberRe.matcher(content).region(offset, content.length()); if (matcher.lookingAt()) { MatchResult matchResult = matcher.toMatchResult(); if (checkHouseNumber(matchResult.group(0))) return matchResult; } return null; } private  FindAddress(); }
FindAddress { @VisibleForTesting public static MatchResult matchHouseNumber(String content, int offset) { if (offset > 0 && HOUSE_PRE_DELIM.indexOf(content.charAt(offset - 1)) == -1) return null; Matcher matcher = sHouseNumberRe.matcher(content).region(offset, content.length()); if (matcher.lookingAt()) { MatchResult matchResult = matcher.toMatchResult(); if (checkHouseNumber(matchResult.group(0))) return matchResult; } return null; } private  FindAddress(); @VisibleForTesting static MatchResult matchHouseNumber(String content, int offset); @VisibleForTesting static MatchResult matchState(String content, int offset); @VisibleForTesting static boolean isValidZipCode(String zipCode, String state); @VisibleForTesting static boolean isValidZipCode(String zipCode); @VisibleForTesting static boolean isValidLocationName(String location); }
FindAddress { @VisibleForTesting public static MatchResult matchHouseNumber(String content, int offset) { if (offset > 0 && HOUSE_PRE_DELIM.indexOf(content.charAt(offset - 1)) == -1) return null; Matcher matcher = sHouseNumberRe.matcher(content).region(offset, content.length()); if (matcher.lookingAt()) { MatchResult matchResult = matcher.toMatchResult(); if (checkHouseNumber(matchResult.group(0))) return matchResult; } return null; } private  FindAddress(); @VisibleForTesting static MatchResult matchHouseNumber(String content, int offset); @VisibleForTesting static MatchResult matchState(String content, int offset); @VisibleForTesting static boolean isValidZipCode(String zipCode, String state); @VisibleForTesting static boolean isValidZipCode(String zipCode); @VisibleForTesting static boolean isValidLocationName(String location);  }