当前位置: 首页>>代码示例>>Java>>正文


Java InsightsResponse类代码示例

本文整理汇总了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;
}
 
开发者ID:jorcox,项目名称:GeoCrawler,代码行数:56,代码来源:GeoIPDocumentCreator.java

示例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);
}
 
开发者ID:maxmind,项目名称:GeoIP2-java,代码行数:9,代码来源:WebServiceClient.java


注:本文中的com.maxmind.geoip2.model.InsightsResponse类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。