Class IPResult

java.lang.Object
co.mindus.ip2location.IPResult

public class IPResult extends Object
Low-level result object from IP2Location BIN database queries.

This class holds the complete set of fields that can be returned from an IP2Location database lookup. The availability of each field depends on the database type being used.

For high-level usage, prefer GeoLocation which is returned by IP2LocationService.lookup(String). This class is primarily used internally by the BIN file reader.

Status Values

StatusMeaning
OKQuery successful
EMPTY_IP_ADDRESSIP address was null or empty
INVALID_IP_ADDRESSIP address format was invalid
IP_ADDRESS_NOT_FOUNDIP not found in database
MISSING_FILEDatabase file not loaded
IPV6_NOT_SUPPORTEDDatabase doesn't support IPv6
DATABASE_ERRORI/O error during query

Field Availability

FieldLITE DatabasesCommercial
Country (short/long)AllAll
Region, CityDB3+DB3+
Latitude, LongitudeDB5+DB5+
ZIP CodeDB9+DB9+
TimezoneDB11+DB11+
ISP, Domain-Commercial only
ASN, AS-Commercial only

Thread Safety

This class is mutable and not thread-safe. Each query produces a new instance.

Author:
Christopher Mindus
See Also:
  • Method Details

    • getIpAddress

      public String getIpAddress()
      Returns the queried IP address.
      Returns:
      The IP address string that was queried
    • getStatus

      public String getStatus()
      Returns the query status.
      Returns:
      Status string (e.g., "OK", "INVALID_IP_ADDRESS")
    • getCountryShort

      public String getCountryShort()
      Returns the ISO 3166-1 alpha-2 country code.
      Returns:
      Two-letter country code (e.g., "US"), or "-" if unavailable
    • getCountryLong

      public String getCountryLong()
      Returns the full country name.
      Returns:
      Country name (e.g., "United States of America"), or "-" if unavailable
    • getRegion

      public String getRegion()
      Returns the region or state name.
      Returns:
      Region name (e.g., "California"), or "-" if unavailable
    • getCity

      public String getCity()
      Returns the city name.
      Returns:
      City name (e.g., "Mountain View"), or "-" if unavailable
    • getLatitude

      public Float getLatitude()
      Returns the latitude.
      Returns:
      Latitude in decimal degrees, or 0.0 if unavailable
    • getLongitude

      public Float getLongitude()
      Returns the longitude.
      Returns:
      Longitude in decimal degrees, or 0.0 if unavailable
    • getZipCode

      public String getZipCode()
      Returns the ZIP or postal code.
      Returns:
      ZIP/postal code string, or "-" if unavailable
    • getTimeZone

      public String getTimeZone()
      Returns the timezone.
      Returns:
      Timezone in tz database format, or "-" if unavailable
    • getISP

      public String getISP()
      Returns the ISP name.
      Returns:
      Internet Service Provider name, or "-" if unavailable
    • getDomain

      public String getDomain()
      Returns the domain name.
      Returns:
      Domain name, or "-" if unavailable
    • getNetSpeed

      public String getNetSpeed()
      Returns the network speed category.
      Returns:
      Speed category (e.g., "DSL", "COMP"), or "-" if unavailable
    • getIDDCode

      public String getIDDCode()
      Returns the IDD code.
      Returns:
      International Direct Dialing code, or "-" if unavailable
    • getAreaCode

      public String getAreaCode()
      Returns the area code.
      Returns:
      Area code, or "-" if unavailable
    • getMCC

      public String getMCC()
      Returns the Mobile Country Code.
      Returns:
      MCC, or "-" if unavailable
    • getMNC

      public String getMNC()
      Returns the Mobile Network Code.
      Returns:
      MNC, or "-" if unavailable
    • getMobileBrand

      public String getMobileBrand()
      Returns the mobile carrier brand name.
      Returns:
      Mobile brand name, or "-" if unavailable
    • getWeatherStationCode

      public String getWeatherStationCode()
      Returns the weather station code.
      Returns:
      Weather station code, or "-" if unavailable
    • getWeatherStationName

      public String getWeatherStationName()
      Returns the weather station name.
      Returns:
      Weather station name, or "-" if unavailable
    • getElevation

      public String getElevation()
      Returns the elevation.
      Returns:
      Elevation in meters, or "-" if unavailable
    • getUsageType

      public String getUsageType()
      Returns the usage type.
      Returns:
      Usage type (e.g., "ISP", "CDN", "DCH"), or "-" if unavailable
    • getAddressType

      public String getAddressType()
      Returns the address type.
      Returns:
      Address type (e.g., "Anycast", "Unicast"), or "-" if unavailable
    • getCategory

      public String getCategory()
      Returns the IAB category.
      Returns:
      Category string, or "-" if unavailable
    • getDistrict

      public String getDistrict()
      Returns the district name.
      Returns:
      District name, or "-" if unavailable
    • getASN

      public String getASN()
      Returns the Autonomous System Number.
      Returns:
      ASN, or "-" if unavailable
    • getAS

      public String getAS()
      Returns the Autonomous System name.
      Returns:
      AS name, or "-" if unavailable
    • getASDomain

      public String getASDomain()
      Returns the Autonomous System domain name.
      Returns:
      AS domain, or "-" if unavailable
    • getASUsageType

      public String getASUsageType()
      Returns the Autonomous System usage type.
      Returns:
      AS usage type, or "-" if unavailable
    • getASCIDR

      public String getASCIDR()
      Returns the Autonomous System CIDR.
      Returns:
      AS CIDR, or "-" if unavailable
    • toString

      public String toString()
      Returns a string representation of this result.
      Overrides:
      toString in class Object
      Returns:
      Human-readable string with key fields
    • hashCode

      public int hashCode()
      Returns a hash code for this result.
      Overrides:
      hashCode in class Object
      Returns:
      The hash code.
    • equals

      public boolean equals(Object obj)
      Compares this result with another for equality.
      Overrides:
      equals in class Object
      Returns:
      The equality state.