@Override public void parse(String field, Data data) { Parser p = new Parser(field); data.strCity = convertCodes(p.getLastOptional(','), CITY_CODES); parseAddress(p.get(';'), data); String place = p.get(); if (place.startsWith("#")) { data.strApt = append(data.strApt, "-", place.substring(1).trim()); } else { data.strPlace = place; } }
@Override public void parse(String field, Data data) { Matcher match = ADDR_PTN.matcher(field); if (match.find()) field = field.substring(0, match.start()).trim(); Parser p = new Parser(field.trim()); data.strCity = p.getLastOptional(':'); String place = p.getLastOptional(';'); parseAddress(p.get(), data); place = stripFieldStart(place, "U:"); match = ADDR_APT_PTN.matcher(place); if (match.matches()) { String apt = match.group(1); if (apt == null) apt = match.group(2).replace(" ", ""); data.strApt = append(data.strApt, "-", apt); place = getOptGroup(match.group(3)); } if (ADDR_BOUND_PTN.matcher(place).matches()) { data.strAddress = append(data.strAddress, " ", place); } else { data.strPlace = place; } }