@Test public void testNumberPrefixCases() { Assert.assertEquals( FindAddress.findAddress("Cafe 21\n750 Fifth Ave. San Diego, California 92101"), "750 Fifth Ave. San Diego, California 92101"); Assert.assertEquals( FindAddress.findAddress( "Century City 15\n 10250 Santa Monica Boulevard Los Angeles, CA 90067"), "10250 Santa Monica Boulevard Los Angeles, CA 90067"); Assert.assertEquals(FindAddress.findAddress("123 45\n67 My Street, Somewhere, NY 10000"), "67 My Street, Somewhere, NY 10000"); assertIsAddress("123 4th Avenue, Somewhere in NY 10000"); }
static String findAddress(String content) { Matcher houseNumberMatcher = sHouseNumberRe.matcher(content); int start = 0; while (houseNumberMatcher.find(start)) { if (checkHouseNumber(houseNumberMatcher.group(0))) { start = houseNumberMatcher.start(); int end = attemptMatch(content, houseNumberMatcher); if (end > 0) { return content.substring(start, end); } start = -end; } else { start = houseNumberMatcher.end(); } } return null; }
FindAddress { static String findAddress(String content) { Matcher houseNumberMatcher = sHouseNumberRe.matcher(content); int start = 0; while (houseNumberMatcher.find(start)) { if (checkHouseNumber(houseNumberMatcher.group(0))) { start = houseNumberMatcher.start(); int end = attemptMatch(content, houseNumberMatcher); if (end > 0) { return content.substring(start, end); } start = -end; } else { start = houseNumberMatcher.end(); } } return null; } }
FindAddress { static String findAddress(String content) { Matcher houseNumberMatcher = sHouseNumberRe.matcher(content); int start = 0; while (houseNumberMatcher.find(start)) { if (checkHouseNumber(houseNumberMatcher.group(0))) { start = houseNumberMatcher.start(); int end = attemptMatch(content, houseNumberMatcher); if (end > 0) { return content.substring(start, end); } start = -end; } else { start = houseNumberMatcher.end(); } } return null; } private  FindAddress(); }
FindAddress { static String findAddress(String content) { Matcher houseNumberMatcher = sHouseNumberRe.matcher(content); int start = 0; while (houseNumberMatcher.find(start)) { if (checkHouseNumber(houseNumberMatcher.group(0))) { start = houseNumberMatcher.start(); int end = attemptMatch(content, houseNumberMatcher); if (end > 0) { return content.substring(start, end); } start = -end; } else { start = houseNumberMatcher.end(); } } 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 { static String findAddress(String content) { Matcher houseNumberMatcher = sHouseNumberRe.matcher(content); int start = 0; while (houseNumberMatcher.find(start)) { if (checkHouseNumber(houseNumberMatcher.group(0))) { start = houseNumberMatcher.start(); int end = attemptMatch(content, houseNumberMatcher); if (end > 0) { return content.substring(start, end); } start = -end; } else { start = houseNumberMatcher.end(); } } 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);  }