public static enum GeoLocation.Status extends Enum<GeoLocation.Status>
This enum provides type-safe status codes for geolocation lookup results, replacing the previous string constants. Each status has a corresponding string code for backward compatibility and logging purposes.
GeoLocation loc = service.lookup("8.8.8.8");
switch (loc.getStatus()) {
case OK:
System.out.println("Country: " + loc.getCountryCode());
break;
case NOT_FOUND:
System.out.println("IP not in database");
break;
case SERVICE_DISABLED:
System.out.println("Geolocation is disabled");
break;
default:
System.err.println("Error: " + loc.getStatus().getCode());
}
| Enum Constant and Description |
|---|
DB_ERROR
An I/O error occurred during the lookup.
|
DB_NOT_LOADED
No database is currently loaded.
|
EMPTY_IP
The IP address was null or empty.
|
INVALID_IP
The IP address format was invalid.
|
IPV6_NOT_SUPPORTED
IPv6 lookup was attempted but no IPv6 database is loaded.
|
NOT_FOUND
The IP address was not found in the database.
|
OK
Lookup was successful.
|
SERVICE_DISABLED
The service is disabled.
|
SERVICE_DISPOSED
The service has been disposed.
|
SERVICE_NOT_CONFIGURED
The manager has not been configured yet.
|
SERVICE_RECONFIGURING
The service is currently being reconfigured.
|
SERVICE_SHUTDOWN
The manager has been shut down.
|
| Modifier and Type | Method and Description |
|---|---|
static GeoLocation.Status |
fromCode(String code)
Finds a status by its string code.
|
static GeoLocation.Status |
fromCodeOrDefault(String code,
GeoLocation.Status defaultValue)
Finds a status by its string code, returning a default if not found.
|
String |
getCode()
Returns the string code for this status.
|
String |
toString()
Returns the string code for this status.
|
static GeoLocation.Status |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static GeoLocation.Status[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final GeoLocation.Status OK
All applicable fields for the database type are populated with valid data.
public static final GeoLocation.Status EMPTY_IP
The lookup method was called with a null or whitespace-only string.
public static final GeoLocation.Status INVALID_IP
The string could not be parsed as either a valid IPv4 or IPv6 address.
public static final GeoLocation.Status NOT_FOUND
The IP address was valid but not present in the loaded database. This can occur for reserved/private IP ranges, very new allocations, or IP ranges not covered by the LITE database.
public static final GeoLocation.Status DB_NOT_LOADED
The service has not yet loaded any database files. This typically occurs during initialization or after a failed database download.
public static final GeoLocation.Status IPV6_NOT_SUPPORTED
To enable IPv6 lookups, configure the service with
IP2LocationService.Builder.includeIPv6(boolean) set to true.
public static final GeoLocation.Status DB_ERROR
This typically indicates a problem reading the database file, such as disk errors, file corruption, or the file being unexpectedly modified.
public static final GeoLocation.Status SERVICE_DISABLED
The service was configured with IP2LocationService.Builder.enabled(boolean)
set to false. No databases are loaded and lookups cannot be performed.
IP2LocationService.isEnabled()public static final GeoLocation.Status SERVICE_DISPOSED
The IP2LocationService.dispose() method was called, releasing all
resources. The service can no longer perform lookups.
public static final GeoLocation.Status SERVICE_SHUTDOWN
The IP2LocationManager.shutdown() method was called. The manager
can no longer perform lookups or be reconfigured.
public static final GeoLocation.Status SERVICE_NOT_CONFIGURED
A lookup was attempted on IP2LocationManager before calling
IP2LocationManager.configure(IP2LocationService.Builder) or
IP2LocationManager.configureAsync(IP2LocationService.Builder, IInitializationCallback).
public static final GeoLocation.Status SERVICE_RECONFIGURING
A lookup was attempted during the brief window when the service is transitioning between configurations. This is rare and transient.
public static GeoLocation.Status[] values()
for (GeoLocation.Status c : GeoLocation.Status.values()) System.out.println(c);
public static GeoLocation.Status valueOf(String name)
name - the name of the enum constant to be returned.IllegalArgumentException - if this enum type has no constant with the specified nameNullPointerException - if the argument is nullpublic String getCode()
This is useful for logging, serialization, or backward compatibility with code that expects string status codes.
public String toString()
This override ensures that logging and string concatenation produce the expected string code rather than the enum name.
toString in class Enum<GeoLocation.Status>public static GeoLocation.Status fromCode(String code)
This method enables backward compatibility with code that uses string status codes, such as status codes returned from the underlying IP2Location BIN reader.
code - The string code to search for (case-sensitive)IllegalArgumentException - if no status matches the codeNullPointerException - if code is nullpublic static GeoLocation.Status fromCodeOrDefault(String code, GeoLocation.Status defaultValue)
This is useful when parsing status codes that might not match any known status, such as unexpected responses from the database reader.
code - The string code to search for (case-sensitive)defaultValue - The value to return if no status matchesPhantom® and NetPhantom® are registered trademarks of Mindus SARL.
© 2026 Mindus SARL. All rights reserved.