@Singleton public class IP2CGeolocator extends java.lang.Object implements Geolocator
Geolocator
implementation using ip2c.Constructor and Description |
---|
IP2CGeolocator() |
Modifier and Type | Method and Description |
---|---|
java.util.Optional<java.lang.String> |
getCountry(java.net.InetAddress inetAddress) |
java.util.Optional<java.lang.String> |
getCountry(java.lang.String address) |
void |
prepare()
Do everything that is needed for the geolocator to function.
|
java.lang.String |
readAnswer(java.io.InputStream is) |
java.util.Optional<java.lang.String> |
readIPFromURL(java.lang.String address) |
java.util.Optional<java.lang.String> |
resolveIP(java.lang.String s) |
public void prepare() throws java.io.IOException
Geolocator
prepare
in interface Geolocator
java.io.IOException
- If the preparation failsjava.net.UnknownHostException
- If preparation requires internet, but internet is not available.public java.util.Optional<java.lang.String> getCountry(java.net.InetAddress inetAddress)
getCountry
in interface Geolocator
public java.util.Optional<java.lang.String> getCountry(java.lang.String address)
getCountry
in interface Geolocator
public java.util.Optional<java.lang.String> readIPFromURL(java.lang.String address) throws java.io.IOException
java.io.IOException
public java.util.Optional<java.lang.String> resolveIP(java.lang.String s)
public java.lang.String readAnswer(java.io.InputStream is) throws java.io.IOException
java.io.IOException