public class DatabaseReader extends Object implements com.maxmind.geoip2.GeoIp2Provider, Closeable
This class was copied from https://raw.githubusercontent.com/maxmind/GeoIP2-java/master/src/main/java/com/maxmind/geoip2/DatabaseReader.java It is written by Maxmind and it is available under Apache Software License V2 The modification we're making to the code below is to stop using exceptions for mainline flow control. Specifically we don't want to throw an exception simply because an address was not found.
Instances of this class provide a reader for the GeoIP2 database format. IP addresses can be looked up using theget method.| Modifier and Type | Class and Description |
|---|---|
static class |
DatabaseReader.Builder
Constructs a Builder for the DatabaseReader.
|
| Modifier and Type | Field and Description |
|---|---|
private com.fasterxml.jackson.databind.ObjectMapper |
om |
private com.maxmind.db.Reader |
reader |
| Modifier | Constructor and Description |
|---|---|
private |
DatabaseReader(DatabaseReader.Builder builder) |
| Modifier and Type | Method and Description |
|---|---|
com.maxmind.geoip2.model.AnonymousIpResponse |
anonymousIp(InetAddress ipAddress)
Look up an IP address in a GeoIP2 Anonymous IP.
|
com.maxmind.geoip2.model.CityResponse |
city(InetAddress ipAddress) |
void |
close()
Closes the database.
|
com.maxmind.geoip2.model.ConnectionTypeResponse |
connectionType(InetAddress ipAddress)
Look up an IP address in a GeoIP2 Connection Type database.
|
com.maxmind.geoip2.model.CountryResponse |
country(InetAddress ipAddress) |
com.maxmind.geoip2.model.DomainResponse |
domain(InetAddress ipAddress)
Look up an IP address in a GeoIP2 Domain database.
|
private <T> T |
get(InetAddress ipAddress,
Class<T> cls,
boolean hasTraits,
String type) |
com.maxmind.db.Metadata |
getMetadata() |
com.maxmind.geoip2.model.IspResponse |
isp(InetAddress ipAddress)
Look up an IP address in a GeoIP2 ISP database.
|
private final com.maxmind.db.Reader reader
private final com.fasterxml.jackson.databind.ObjectMapper om
private DatabaseReader(DatabaseReader.Builder builder) throws IOException
IOExceptionprivate <T> T get(InetAddress ipAddress, Class<T> cls, boolean hasTraits, String type) throws IOException, com.maxmind.geoip2.exception.AddressNotFoundException
ipAddress - IPv4 or IPv6 address to lookup.IOException - if there is an error opening or reading from the file.com.maxmind.geoip2.exception.AddressNotFoundExceptionpublic void close()
throws IOException
Closes the database.
If you are using FileMode.MEMORY_MAPPED, this will
not unmap the underlying file due to a limitation in Java's MappedByteBuffer. It will however set the reference to the buffer to null, allowing the garbage
collector to collect it.
close in interface Closeableclose in interface AutoCloseableIOException - if an I/O error occurs.public com.maxmind.geoip2.model.CountryResponse country(InetAddress ipAddress) throws IOException, com.maxmind.geoip2.exception.GeoIp2Exception
country in interface com.maxmind.geoip2.GeoIp2ProviderIOExceptioncom.maxmind.geoip2.exception.GeoIp2Exceptionpublic com.maxmind.geoip2.model.CityResponse city(InetAddress ipAddress) throws IOException, com.maxmind.geoip2.exception.GeoIp2Exception
city in interface com.maxmind.geoip2.GeoIp2ProviderIOExceptioncom.maxmind.geoip2.exception.GeoIp2Exceptionpublic com.maxmind.geoip2.model.AnonymousIpResponse anonymousIp(InetAddress ipAddress) throws IOException, com.maxmind.geoip2.exception.GeoIp2Exception
ipAddress - IPv4 or IPv6 address to lookup.com.maxmind.geoip2.exception.GeoIp2Exception - if there is an error looking up the IPIOException - if there is an IO errorpublic com.maxmind.geoip2.model.ConnectionTypeResponse connectionType(InetAddress ipAddress) throws IOException, com.maxmind.geoip2.exception.GeoIp2Exception
ipAddress - IPv4 or IPv6 address to lookup.com.maxmind.geoip2.exception.GeoIp2Exception - if there is an error looking up the IPIOException - if there is an IO errorpublic com.maxmind.geoip2.model.DomainResponse domain(InetAddress ipAddress) throws IOException, com.maxmind.geoip2.exception.GeoIp2Exception
ipAddress - IPv4 or IPv6 address to lookup.com.maxmind.geoip2.exception.GeoIp2Exception - if there is an error looking up the IPIOException - if there is an IO errorpublic com.maxmind.geoip2.model.IspResponse isp(InetAddress ipAddress) throws IOException, com.maxmind.geoip2.exception.GeoIp2Exception
ipAddress - IPv4 or IPv6 address to lookup.com.maxmind.geoip2.exception.GeoIp2Exception - if there is an error looking up the IPIOException - if there is an IO errorpublic com.maxmind.db.Metadata getMetadata()
Copyright © 2020 Apache NiFi Project. All rights reserved.