Class InetAddressEx

java.lang.Object
org.netxms.base.InetAddressEx

public class InetAddressEx extends Object
Inet address wrapper
  • Field Details

    • address

      protected InetAddress address
    • mask

      protected int mask
  • Constructor Details

    • InetAddressEx

      public InetAddressEx(InetAddress address)
      Create from InetAddress object with default network mask (/32 for IPv4 and /128 for IPv6).
      Parameters:
      address - IP address
    • InetAddressEx

      public InetAddressEx(InetAddress address, int mask)
      Create from InetAddress with given network mask.
      Parameters:
      address - IP address
      mask - network mask bits
    • InetAddressEx

      public InetAddressEx(InetAddress address, InetAddress mask)
      Create from InetAddress with given network mask.
      Parameters:
      address - IP address
      mask - network mask
    • InetAddressEx

      public InetAddressEx(InetAddressEx src)
      Copy constructor
      Parameters:
      src - source object
    • InetAddressEx

      public InetAddressEx()
      Create AF_UNSPEC address
  • Method Details

    • isValidAddress

      public boolean isValidAddress()
      Check if address is a valid IPv4/IPv6 address
      Returns:
      true if address is a valid IPv4/IPv6 address
    • isValidUnicastAddress

      public boolean isValidUnicastAddress()
      Check if address is a valid unicast address
      Returns:
      true if address is a valid unicast address
    • getHostAddress

      public String getHostAddress()
      Get host address as text (without mask length)
      Returns:
      host address as text (without mask length)
    • getAddress

      public InetAddress getAddress()
      Get IP address object
      Returns:
      IP address
    • getMask

      public int getMask()
      Get network mask (bit length)
      Returns:
      network mask bit length
    • setAddress

      public void setAddress(InetAddress address)
      Set IP address
      Parameters:
      address - IP address to set
    • setMask

      public void setMask(int mask)
      Set mask length
      Parameters:
      mask - new mask length
    • getAddressBytes

      public byte[] getAddressBytes()
      Get address bytes
      Returns:
      address bytes
    • getHostBits

      public int getHostBits()
      Get number of bits in host part of the address (address length - mask length).
      Returns:
      number of bits in host part of the address
    • toString

      public String toString()
      Overrides:
      toString in class Object
      See Also:
    • bitsInMask

      public static int bitsInMask(InetAddress mask)
      Calculate number of bits in network mask
      Parameters:
      mask - network mask as IP address
      Returns:
      network mask length (in bits)
    • maskFromBits

      public InetAddress maskFromBits()
      Convert bit count into mask
      Returns:
      network mask as IP address
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
      See Also:
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
      See Also: