public String country(String ipAddress) throws IOException { InetAddress ia = InetAddress.getByName(ipAddress); Object o = get(ia, "Country"); if (!(o instanceof Map)) return null; Map m = (Map) o; o = m.get("country"); if (!(o instanceof Map)) return null; m = (Map) o; o = m.get("iso_code"); if (!(o instanceof String)) return null; return (String) o; }
/** * Look up an IP address in a GeoLite2 ASN database. * * @param ipAddress IPv4 or IPv6 address to lookup. * @return an AsnResponse for the requested IP address. * @throws GeoIp2Exception if there is an error looking up the IP * @throws IOException if there is an IO error */ @Override public AsnResponse asn(InetAddress ipAddress) throws IOException, GeoIp2Exception { return this.get(ipAddress, AsnResponse.class, "GeoLite2-ASN"); }
@Override public CountryResponse country(InetAddress ipAddress) throws IOException, GeoIp2Exception { return this.get(ipAddress, CountryResponse.class, "Country"); }
@Override public CityResponse city(InetAddress ipAddress) throws IOException, GeoIp2Exception { return this.get(ipAddress, CityResponse.class, "City"); }
/** * Look up an IP address in a GeoIP2 Anonymous IP. * * @param ipAddress IPv4 or IPv6 address to lookup. * @return a AnonymousIpResponse for the requested IP address. * @throws GeoIp2Exception if there is an error looking up the IP * @throws IOException if there is an IO error */ @Override public AnonymousIpResponse anonymousIp(InetAddress ipAddress) throws IOException, GeoIp2Exception { return this.get(ipAddress, AnonymousIpResponse.class, "GeoIP2-Anonymous-IP"); }
/** * Look up an IP address in a GeoIP2 ISP database. * * @param ipAddress IPv4 or IPv6 address to lookup. * @return an IspResponse for the requested IP address. * @throws GeoIp2Exception if there is an error looking up the IP * @throws IOException if there is an IO error */ @Override public IspResponse isp(InetAddress ipAddress) throws IOException, GeoIp2Exception { return this.get(ipAddress, IspResponse.class, "GeoIP2-ISP"); }
@Override public CityResponse city(InetAddress ipAddress) throws IOException, GeoIp2Exception { return this.get(ipAddress, CityResponse.class, "City"); }
@Override public CountryResponse country(InetAddress ipAddress) throws IOException, GeoIp2Exception { return this.get(ipAddress, CountryResponse.class, "Country"); }
/** * Look up an IP address in a GeoIP2 Enterprise database. * * @param ipAddress IPv4 or IPv6 address to lookup. * @return an EnterpriseResponse for the requested IP address. * @throws GeoIp2Exception if there is an error looking up the IP * @throws IOException if there is an IO error */ @Override public EnterpriseResponse enterprise(InetAddress ipAddress) throws IOException, GeoIp2Exception { return this.get(ipAddress, EnterpriseResponse.class, "Enterprise"); }
/** * Look up an IP address in a GeoIP2 Domain database. * * @param ipAddress IPv4 or IPv6 address to lookup. * @return a DomainResponse for the requested IP address. * @throws GeoIp2Exception if there is an error looking up the IP * @throws IOException if there is an IO error */ @Override public DomainResponse domain(InetAddress ipAddress) throws IOException, GeoIp2Exception { return this .get(ipAddress, DomainResponse.class, "GeoIP2-Domain"); }
/** * Look up an IP address in a GeoIP2 Enterprise database. * * @param ipAddress IPv4 or IPv6 address to lookup. * @return an EnterpriseResponse for the requested IP address. * @throws GeoIp2Exception if there is an error looking up the IP * @throws IOException if there is an IO error */ @Override public EnterpriseResponse enterprise(InetAddress ipAddress) throws IOException, GeoIp2Exception { return this.get(ipAddress, EnterpriseResponse.class, "Enterprise"); }
/** * Look up an IP address in a GeoIP2 Anonymous IP. * * @param ipAddress IPv4 or IPv6 address to lookup. * @return a AnonymousIpResponse for the requested IP address. * @throws GeoIp2Exception if there is an error looking up the IP * @throws IOException if there is an IO error */ @Override public AnonymousIpResponse anonymousIp(InetAddress ipAddress) throws IOException, GeoIp2Exception { return this.get(ipAddress, AnonymousIpResponse.class, "GeoIP2-Anonymous-IP"); }
/** * Look up an IP address in a GeoIP2 ISP database. * * @param ipAddress IPv4 or IPv6 address to lookup. * @return an IspResponse for the requested IP address. * @throws GeoIp2Exception if there is an error looking up the IP * @throws IOException if there is an IO error */ @Override public IspResponse isp(InetAddress ipAddress) throws IOException, GeoIp2Exception { return this.get(ipAddress, IspResponse.class, "GeoIP2-ISP"); }
/** * Look up an IP address in a GeoLite2 ASN database. * * @param ipAddress IPv4 or IPv6 address to lookup. * @return an AsnResponse for the requested IP address. * @throws GeoIp2Exception if there is an error looking up the IP * @throws IOException if there is an IO error */ @Override public AsnResponse asn(InetAddress ipAddress) throws IOException, GeoIp2Exception { return this.get(ipAddress, AsnResponse.class, "GeoLite2-ASN"); }
/** * Look up an IP address in a GeoIP2 Connection Type database. * * @param ipAddress IPv4 or IPv6 address to lookup. * @return a ConnectTypeResponse for the requested IP address. * @throws GeoIp2Exception if there is an error looking up the IP * @throws IOException if there is an IO error */ @Override public ConnectionTypeResponse connectionType(InetAddress ipAddress) throws IOException, GeoIp2Exception { return this.get(ipAddress, ConnectionTypeResponse.class, "GeoIP2-Connection-Type"); }
/** * Look up an IP address in a GeoIP2 Connection Type database. * * @param ipAddress IPv4 or IPv6 address to lookup. * @return a ConnectTypeResponse for the requested IP address. * @throws GeoIp2Exception if there is an error looking up the IP * @throws IOException if there is an IO error */ @Override public ConnectionTypeResponse connectionType(InetAddress ipAddress) throws IOException, GeoIp2Exception { return this.get(ipAddress, ConnectionTypeResponse.class, "GeoIP2-Connection-Type"); }
/** * Look up an IP address in a GeoIP2 Domain database. * * @param ipAddress IPv4 or IPv6 address to lookup. * @return a DomainResponse for the requested IP address. * @throws GeoIp2Exception if there is an error looking up the IP * @throws IOException if there is an IO error */ @Override public DomainResponse domain(InetAddress ipAddress) throws IOException, GeoIp2Exception { return this .get(ipAddress, DomainResponse.class, "GeoIP2-Domain"); }