private Record createRecord(final Subdivision subdivision) { if (subdivision == null) { return null; } final Map<String, Object> values = new HashMap<>(2); values.put(CitySchema.SUBDIVISION_NAME.getFieldName(), subdivision.getName()); values.put(CitySchema.SUBDIVISION_ISO.getFieldName(), subdivision.getIsoCode()); return new MapRecord(CitySchema.SUBDIVISION_SCHEMA, values); }
attrs.put(new StringBuilder(ipAttributeName).append(".geo.subdivision.").append(i).toString(), subd.getName()); attrs.put(new StringBuilder(ipAttributeName).append(".geo.subdivision.isocode.").append(i).toString(), subd.getIsoCode()); i++;
@Override public String getValue(CityResponse response) { return response.getLeastSpecificSubdivision().getName(); } },
private GeoInfo _getGeoInfo(String ipAddress) { GeoInfo geoInfo = new GeoInfo(); if (ipAddress == null) { return geoInfo; } try{ InetAddress inetAddress = InetAddress.getByName(ipAddress); CityResponse response = reader.city(inetAddress); Country country = response.getCountry(); Continent continent = response.getContinent(); City city = response.getCity(); Postal postal = response.getPostal(); Location location = response.getLocation(); Subdivision subdivision = response.getMostSpecificSubdivision(); geoInfo.setRegion(subdivision.getName()); geoInfo.setCountryIsoCode(country.getIsoCode()); geoInfo.setCountry(country.getName()); geoInfo.setContinent(continent.getCode()); geoInfo.setCity(city.getName()); geoInfo.setPostalCode(postal.getCode()); geoInfo.setLatitude(location.getLatitude()); geoInfo.setLongitude(location.getLongitude()); return geoInfo; } catch(Exception ex){ return null; } }
attrs.put(new StringBuilder(ipAttributeName).append(".geo.subdivision.").append(i).toString(), subd.getName()); attrs.put(new StringBuilder(ipAttributeName).append(".geo.subdivision.isocode.").append(i).toString(), subd.getIsoCode()); i++;
attrs.put(new StringBuilder(ipAttributeName).append(".geo.subdivision.").append(i).toString(), subd.getName()); attrs.put(new StringBuilder(ipAttributeName).append(".geo.subdivision.isocode.").append(i).toString(), subd.getIsoCode()); i++;
name.append(subd.getIsoCode()); else name.append(subd.getName());
geo.put("subdivision_name", response.getMostSpecificSubdivision().getName()); break; case SUBDIVISION_ISO_CODE:
geo.put("subdivision_name", response.getMostSpecificSubdivision().getName()); break; case SUBDIVISION_ISO_CODE:
if (subdivision != null) { if (wantSubdivisionName) { parsable.addDissection(inputname, "STRING", "subdivision.name", subdivision.getName());