本文整理汇总了Java中com.maxmind.geoip2.model.InsightsResponse类的典型用法代码示例。如果您正苦于以下问题:Java InsightsResponse类的具体用法?Java InsightsResponse怎么用?Java InsightsResponse使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
InsightsResponse类属于com.maxmind.geoip2.model包,在下文中一共展示了InsightsResponse类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createDocFromInsightsService
import com.maxmind.geoip2.model.InsightsResponse; //导入依赖的package包/类
public static NutchDocument createDocFromInsightsService(String serverIp,
NutchDocument doc, WebServiceClient client) throws UnknownHostException,
IOException, GeoIp2Exception {
doc.add("ip", serverIp);
InsightsResponse response = client
.insights(InetAddress.getByName(serverIp));
// CityResponse response = client.city(InetAddress.getByName(serverIp));
City city = response.getCity();
doc.add("cityName", city.getName()); // 'Minneapolis'
doc.add("cityConfidence", city.getConfidence()); // 50
doc.add("cityGeoNameId", city.getGeoNameId());
Continent continent = response.getContinent();
doc.add("continentCode", continent.getCode());
doc.add("continentGeoNameId", continent.getGeoNameId());
doc.add("continentName", continent.getName());
Country country = response.getCountry();
doc.add("countryIsoCode", country.getIsoCode()); // 'US'
doc.add("countryName", country.getName()); // 'United States'
doc.add("countryConfidence", country.getConfidence()); // 99
doc.add("countryGeoName", country.getGeoNameId());
Location location = response.getLocation();
doc.add("latLon", location.getLatitude() + "," + location.getLongitude()); // 44.9733,
// -93.2323
doc.add("accRadius", location.getAccuracyRadius()); // 3
doc.add("timeZone", location.getTimeZone()); // 'America/Chicago'
doc.add("metroCode", location.getMetroCode());
Postal postal = response.getPostal();
doc.add("postalCode", postal.getCode()); // '55455'
doc.add("postalConfidence", postal.getConfidence()); // 40
RepresentedCountry rCountry = response.getRepresentedCountry();
doc.add("countryType", rCountry.getType());
Subdivision subdivision = response.getMostSpecificSubdivision();
doc.add("subDivName", subdivision.getName()); // 'Minnesota'
doc.add("subDivIdoCode", subdivision.getIsoCode()); // 'MN'
doc.add("subDivConfidence", subdivision.getConfidence()); // 90
doc.add("subDivGeoNameId", subdivision.getGeoNameId());
Traits traits = response.getTraits();
doc.add("autonSystemNum", traits.getAutonomousSystemNumber());
doc.add("autonSystemOrg", traits.getAutonomousSystemOrganization());
doc.add("domain", traits.getDomain());
doc.add("isp", traits.getIsp());
doc.add("org", traits.getOrganization());
doc.add("userType", traits.getUserType());
doc.add("isAnonProxy", traits.isAnonymousProxy());
doc.add("isSatelliteProv", traits.isSatelliteProvider());
return doc;
}
示例2: insights
import com.maxmind.geoip2.model.InsightsResponse; //导入依赖的package包/类
/**
* @return An Insights model for the requesting IP address
* @throws GeoIp2Exception if there is an error from the web service
* @throws IOException if an IO error happens during the request
*/
public InsightsResponse insights() throws IOException, GeoIp2Exception {
return this.insights(null);
}