Class InetAddressMask

java.lang.Object
marauroa.server.net.validator.InetAddressMask

public class InetAddressMask extends Object
This class is a mask that determines if a IPv4 address match with the mask. It works only for IPv4 addresses
  • Constructor Details

    • InetAddressMask

      public InetAddressMask(String address, String mask)
      creates a new InetAddressMask object.
      Parameters:
      address - address in form aaa.bbb.ccc.ddd
      mask - network mask in form aaa.bbb.ccc.ddd
    • InetAddressMask

      public InetAddressMask(byte[] address, byte[] mask)
      creates a new InetAddressMask object.
      Parameters:
      address - address
      mask - network mask
  • Method Details

    • matches

      public boolean matches(InetAddress anotherAddress)
      checks whether the provided InetAddress object is within the range specified in this object.
      Parameters:
      anotherAddress - address to check
      Returns:
      true if it is within this range, false otherwise
    • hashCode

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

      public boolean equals(Object object)
      Overrides:
      equals in class Object
    • toString

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

      public static byte[] string2bytes(String ipv4Address)
      converts string in form aaa.bbb.ccc.ddd into byte array[]{aaa,bbb,ccc,ddd}
      Parameters:
      ipv4Address - address string
      Returns:
      byte array