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); }
for(Subdivision sub: subdivision) { Map<String, Object> subdivisioninfo = new HashMap<>(2); Optional.ofNullable(sub.getIsoCode()).ifPresent(i -> subdivisioninfo.put("code", i)); Optional.ofNullable(sub.getNames().get(locale)).ifPresent(i -> subdivisioninfo.put("name", i)); if(subdivisioninfo.size() > 0) { all.add(subdivisioninfo);
address.setZone(response.getMostSpecificSubdivision().getIsoCode()); address.setCity(response.getCity().getName());
@Override public String getValue(CityResponse response) { return response.getLeastSpecificSubdivision().getName(); } },
/** * @return An object representing the least specific subdivision returned. If * the response did not contain any subdivisions, this method * returns an empty {@link Subdivision} object. */ @JsonIgnore public Subdivision getLeastSpecificSubdivision() { if (this.subdivisions.isEmpty()) { return new Subdivision(); } return this.subdivisions.get(0); } }
session.setProperty("sessionAdminSubDiv1", cityResponse.getSubdivisions().get(0).getGeoNameId()); session.setProperty("sessionAdminSubDiv2", cityResponse.getSubdivisions().get(1).getGeoNameId());
@Override public String getValue(CityResponse response) { return response.getLeastSpecificSubdivision().getIsoCode(); } },
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; } }
/** * @return An object representing the least specific subdivision returned. If * the response did not contain any subdivisions, this method * returns an empty {@link Subdivision} object. */ @JsonIgnore public Subdivision getLeastSpecificSubdivision() { if (this.subdivisions.isEmpty()) { return new Subdivision(); } return this.subdivisions.get(0); } }
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++;
/** * @return An object representing the most specific subdivision returned. If * the response did not contain any subdivisions, this method * returns an empty {@link Subdivision} object. */ @JsonIgnore public Subdivision getMostSpecificSubdivision() { if (this.subdivisions.isEmpty()) { return new Subdivision(); } return this.subdivisions.get(this.subdivisions.size() - 1); }
if (name.length()>0) name.append(", "); if (!Strings.isBlank(subd.getIsoCode())) name.append(subd.getIsoCode()); else name.append(subd.getName());
/** * @return An object representing the most specific subdivision returned. If * the response did not contain any subdivisions, this method * returns an empty {@link Subdivision} object. */ @JsonIgnore public Subdivision getMostSpecificSubdivision() { if (this.subdivisions.isEmpty()) { return new Subdivision(); } return this.subdivisions.get(this.subdivisions.size() - 1); }
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++;
geo.put("subdivision_name", response.getMostSpecificSubdivision().getName()); break; case SUBDIVISION_ISO_CODE: geo.put("subdivision_iso_code", response.getMostSpecificSubdivision().getIsoCode()); break; case CITY_NAME:
geo.put("subdivision_name", response.getMostSpecificSubdivision().getName()); break; case SUBDIVISION_ISO_CODE: geo.put("subdivision_iso_code", response.getMostSpecificSubdivision().getIsoCode()); break; case CITY_NAME:
if (subdivision != null) { if (wantSubdivisionName) { parsable.addDissection(inputname, "STRING", "subdivision.name", subdivision.getName()); parsable.addDissection(inputname, "STRING", "subdivision.iso", subdivision.getIsoCode());