Class Ipv4Range

java.lang.Object
com.baremaps.iploc.data.Ipv4Range

public class Ipv4Range extends Object
Represents an IP range from a start IP to an end IP stored into longs because Java and Sqlite do not have unsigned 32 bits integers
  • Constructor Summary

    Constructors
    Constructor
    Description
    Ipv4Range(byte[] start, byte[] end)
    Constructs an Ipv4 range from a start and end ips
    Constructs an Ipv4 range from a String
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    format(byte[] ip)
    Format an IP from a byte array into a string We need to prepend a byte of value 0 to the byte array so that the MSB is 0 in the two's-complement binary representation
    byte[]
    Returns the last IP in the range
    byte[]
    Returns the first IP in the range
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Ipv4Range

      public Ipv4Range(String range)
      Constructs an Ipv4 range from a String
      Parameters:
      range - the range in format "192.168.0.1 - 192.168.0.255" or "192.168.0.1/24"
    • Ipv4Range

      public Ipv4Range(byte[] start, byte[] end)
      Constructs an Ipv4 range from a start and end ips
      Parameters:
      start -
      end -
  • Method Details

    • format

      public static String format(byte[] ip)
      Format an IP from a byte array into a string We need to prepend a byte of value 0 to the byte array so that the MSB is 0 in the two's-complement binary representation
      Parameters:
      ip - the IP in a byte array
      Returns:
      teh formatted IP
    • getStart

      public byte[] getStart()
      Returns the first IP in the range
      Returns:
      the first IP in the range
    • getEnd

      public byte[] getEnd()
      Returns the last IP in the range
      Returns:
      the last IP in the range
    • toString

      public String toString()
      Overrides:
      toString in class Object