Class InetAddressMask

All Implemented Interfaces:
Initable, Proxy

@Generated("org.javagi.JavaGI") public class InetAddressMask extends GObject implements Initable
GInetAddressMask represents a range of IPv4 or IPv6 addresses described by a base address and a length indicating how many bits of the base address are relevant for matching purposes. These are often given in string form. For example, 10.0.0.0/8, or fe80::/10.
Since:
2.32
  • Constructor Details

    • InetAddressMask

      public InetAddressMask(MemorySegment address)
      Create a InetAddressMask instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
    • InetAddressMask

      public InetAddressMask(InetAddress addr, int length) throws GErrorException
      Creates a new GInetAddressMask representing all addresses whose first length bits match addr.
      Parameters:
      addr - a GInetAddress
      length - number of bits of addr to use
      Throws:
      GErrorException - see GError
      Since:
      2.32
    • InetAddressMask

      public InetAddressMask()
      Create a new InetAddressMask.
  • Method Details

    • getType

      public static @Nullable Type getType()
      Get the GType of the InetAddressMask class.
      Returns:
      the GType
    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      The memory layout of the native struct.
      Returns:
      the memory layout
    • asParent

      protected InetAddressMask asParent()
      Return this instance as if it were its parent type. Comparable to the Java super keyword, but ensures the parent typeclass is also used in native code.
      Overrides:
      asParent in class GObject
      Returns:
      the instance as if it were its parent type
    • fromString

      public static InetAddressMask fromString(String maskString) throws GErrorException
      Parses maskString as an IP address and (optional) length, and creates a new GInetAddressMask. The length, if present, is delimited by a "/". If it is not present, then the length is assumed to be the full length of the address.
      Parameters:
      maskString - an IP address or address/length string
      Returns:
      a new GInetAddressMask corresponding to string, or null on error.
      Throws:
      GErrorException - see GError
      Since:
      2.32
    • equal

      public boolean equal(InetAddressMask mask2)
      Tests if this InetAddressMask and mask2 are the same mask.
      Parameters:
      mask2 - another GInetAddressMask
      Returns:
      whether this InetAddressMask and mask2 are the same mask
      Since:
      2.32
    • getAddress

      public InetAddress getAddress()
      Gets mask's base address
      Returns:
      mask's base address
      Since:
      2.32
    • getFamily

      public SocketFamily getFamily()
      Gets the GSocketFamily of mask's address
      Returns:
      the GSocketFamily of mask's address
      Since:
      2.32
    • getLength

      public int getLength()
      Gets mask's length
      Returns:
      mask's length
      Since:
      2.32
    • matches

      public boolean matches(InetAddress address)
      Tests if address falls within the range described by mask.
      Parameters:
      address - a GInetAddress
      Returns:
      whether address falls within the range described by mask.
      Since:
      2.32
    • toString

      public String toString()
      Converts this InetAddressMask back to its corresponding string form.
      Overrides:
      toString in class Object
      Returns:
      a string corresponding to mask.
      Since:
      2.32
    • builder

      public static InetAddressMask.Builder<? extends InetAddressMask.Builder> builder()
      A InetAddressMask.Builder object constructs a InetAddressMask with the specified properties. Use the various set...() methods to set properties, and finish construction with InetAddressMask.Builder.build().
      Returns:
      the builder object