Class IPBlock

java.lang.Object
org.deltava.beans.system.IPBlock
All Implemented Interfaces:
Serializable, Comparable<IPBlock>, GeoLocation, Cacheable

public class IPBlock extends Object implements Cacheable, GeoLocation, Comparable<IPBlock>
A bean to store IP address block information.
Since:
2.5
Version:
10.3
Author:
Luke
See Also:
  • Constructor Details

    • IPBlock

      public IPBlock(int id, String cidr)
      Initializes the bean.
      Parameters:
      id - the block ID
      cidr - the CIDRBlock address
  • Method Details

    • getAddress

      public String getAddress()
      Returns the base Address of the address block.
      Returns:
      the base IP address
    • getLastAddress

      public String getLastAddress()
      Returns the last Address of the address block.
      Returns:
      the last IP address
    • getBits

      public int getBits()
      Returns the size of the address block.
      Returns:
      the size of the block in bits
    • getID

      public int getID()
      Returns the block database ID.
      Returns:
      the ID
    • getSize

      public int getSize()
      Returns the size of the block.
      Returns:
      the number of addresses in the block
    • getType

      public IPAddress getType()
      Returns the IP address type.
      Returns:
      an IPAddress
    • getCountry

      public Country getCountry()
      Returns the country associated with this IP address.
      Returns:
      the Country
      See Also:
    • getRegion

      public String getRegion()
      Returns the region/state associated with this IP address.
      Returns:
      the region name
      See Also:
    • getCity

      public String getCity()
      Returns the city associated with this IP address.
      Returns:
      the city name
      See Also:
    • getLocation

      public String getLocation()
      Returns the city, region and country (if available).
      Returns:
      the location
    • getRadius

      public int getRadius()
      Returns the geolocation accuracy radius.
      Returns:
      the radius in miles
    • getLatitude

      public double getLatitude()
      Description copied from interface: GeoLocation
      Returns the latitude of this location.
      Specified by:
      getLatitude in interface GeoLocation
      Returns:
      the latitude in degrees
    • getLongitude

      public double getLongitude()
      Description copied from interface: GeoLocation
      Returns the longitude of this location.
      Specified by:
      getLongitude in interface GeoLocation
      Returns:
      the longitude in degrees
    • contains

      public boolean contains(String addr)
      Checks whether this IP block contains a specific IP address.
      Parameters:
      addr - the IP address
      Returns:
      TRUE if the block contains the address, otherwise FALSE
    • setCountry

      public void setCountry(Country c)
      Updates the country associated with this address block.
      Parameters:
      c - the Country
      See Also:
    • setRegion

      public void setRegion(String rgn)
      Updates the region/state associated with this address block.
      Parameters:
      rgn - the region name
      See Also:
    • setCity

      public void setCity(String city)
      Updates the city associated with this address block.
      Parameters:
      city - the city name
      See Also:
    • setLocation

      public void setLocation(double lat, double lng)
      Updates the location of this address block.
      Parameters:
      lat - the latitude in degrees
      lng - the longitude in degrees
    • setRadius

      public void setRadius(int radius)
      Sets the geolocaiton accuracy radius.
      Parameters:
      radius - the radius in miles
    • cacheKey

      public Object cacheKey()
      Description copied from interface: Cacheable
      Returns the cache key for this object. Caches call this method when adding the object.
      Specified by:
      cacheKey in interface Cacheable
      Returns:
      the cache key for the object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • compareTo

      public int compareTo(IPBlock o)
      Specified by:
      compareTo in interface Comparable<IPBlock>