Class InetAddressUtils


  • public class InetAddressUtils
    extends java.lang.Object
    A collection of utilities relating to InetAddresses.
    Since:
    4.0
    • Field Detail

      • IPV4_BASIC_PATTERN_STRING

        private static final java.lang.String IPV4_BASIC_PATTERN_STRING
        See Also:
        Constant Field Values
      • IPV4_PATTERN

        private static final java.util.regex.Pattern IPV4_PATTERN
      • IPV4_MAPPED_OCTET

        private static final java.lang.String IPV4_MAPPED_OCTET
        See Also:
        Constant Field Values
      • IPV4_MAPPED_IPV6_PATTERN

        private static final java.util.regex.Pattern IPV4_MAPPED_IPV6_PATTERN
      • IPV6_STD_PATTERN

        private static final java.util.regex.Pattern IPV6_STD_PATTERN
      • IPV6_HEX_COMPRESSED_PATTERN

        private static final java.util.regex.Pattern IPV6_HEX_COMPRESSED_PATTERN
      • SCOPE_ID_PATTERN

        private static final java.util.regex.Pattern SCOPE_ID_PATTERN
        Regular expression pattern to match the scope ID in an IPv6 scoped address. The scope ID should be a non-empty string consisting of only alphanumeric characters or "-".
      • SCOPE_ID_DELIMITER

        private static final char SCOPE_ID_DELIMITER
        Delimiter used to separate an IPv6 address from its scope ID.
        See Also:
        Constant Field Values
    • Constructor Detail

      • InetAddressUtils

        private InetAddressUtils()
    • Method Detail

      • isIPv4Address

        @Deprecated
        public static boolean isIPv4Address​(java.lang.String input)
        Deprecated.
        Tests whether the parameter is a valid IPv4 address
        Parameters:
        input - the address character sequence to check for validity
        Returns:
        true if the input parameter is a valid IPv4 address
      • isIPv4

        public static boolean isIPv4​(java.lang.CharSequence input)
        Tests whether the parameter is a valid IPv4 address.
        Parameters:
        input - the address character sequence to check for validity
        Returns:
        true if the input parameter is a valid IPv4 address
        Since:
        5.3
      • isIPv4MappedIPv64Address

        @Deprecated
        public static boolean isIPv4MappedIPv64Address​(java.lang.String input)
        Tests if an IPv6 address is an IPv4-mapped IPv6 address.
        Parameters:
        input - the IPv6 address to be checked
        Returns:
        true if the IPv6 address is an IPv4-mapped IPv6 address, false otherwise.
      • isIPv4MappedIPv6

        public static boolean isIPv4MappedIPv6​(java.lang.CharSequence input)
        Tests if an IPv6 address is an IPv4-mapped IPv6 address.
        Parameters:
        input - the IPv6 address to be checked
        Returns:
        true if the IPv6 address is an IPv4-mapped IPv6 address, false otherwise.
        Since:
        5.3
      • hasValidIPv6ColonCount

        static boolean hasValidIPv6ColonCount​(java.lang.CharSequence input)
      • isIPv6StdAddress

        @Deprecated
        public static boolean isIPv6StdAddress​(java.lang.String input)
        Deprecated.
        Tests whether the parameter is a valid standard (non-compressed) IPv6 address
        Parameters:
        input - the address character sequence to check for validity
        Returns:
        true if the input parameter is a valid standard (non-compressed) IPv6 address
      • isIPv6Std

        public static boolean isIPv6Std​(java.lang.CharSequence input)
        Tests whether the parameter is a valid standard (non-compressed) IPv6 address
        Parameters:
        input - the address character sequence to check for validity
        Returns:
        true if the input parameter is a valid standard (non-compressed) IPv6 address
        Since:
        5.3
      • isIPv6HexCompressedAddress

        @Deprecated
        public static boolean isIPv6HexCompressedAddress​(java.lang.String input)
        Tests whether the parameter is a valid compressed IPv6 address
        Parameters:
        input - the address character sequence to check for validity
        Returns:
        true if the input parameter is a valid compressed IPv6 address
      • isIPv6HexCompressed

        public static boolean isIPv6HexCompressed​(java.lang.CharSequence input)
        Tests whether the parameter is a valid compressed IPv6 address
        Parameters:
        input - the address character sequence to check for validity
        Returns:
        true if the input parameter is a valid compressed IPv6 address
        Since:
        5.3
      • isIPv6Address

        @Deprecated
        public static boolean isIPv6Address​(java.lang.String input)
        Deprecated.
        Tests whether the parameter is a valid IPv6 address (including compressed).
        Parameters:
        input - the address character sequence to check for validity
        Returns:
        true if the input parameter is a valid standard or compressed IPv6 address
      • isIPv6

        public static boolean isIPv6​(java.lang.CharSequence input)
        Tests whether the parameter is a valid IPv6 address (including compressed).
        Parameters:
        input - the address character sequence to check for validity
        Returns:
        true if the input parameter is a valid standard or compressed IPv6 address
        Since:
        5.3
      • isIPv6URLBracketedAddress

        @Deprecated
        public static boolean isIPv6URLBracketedAddress​(java.lang.String input)
        Tests whether the parameter is a valid URL formatted bracketed IPv6 address (including compressed). This matches only bracketed values e.g. [::1].
        Parameters:
        input - the address character sequence to check for validity
        Returns:
        true if the input parameter is a valid URL-formatted bracketed IPv6 address
      • isIPv6URLBracketed

        public static boolean isIPv6URLBracketed​(java.lang.CharSequence input)
        Tests whether the parameter is a valid URL formatted bracketed IPv6 address (including compressed). This matches only bracketed values e.g. [::1].
        Parameters:
        input - the address character sequence to check for validity
        Returns:
        true if the input parameter is a valid URL-formatted bracketed IPv6 address
        Since:
        5.3
      • formatAddress

        public static void formatAddress​(java.lang.StringBuilder buffer,
                                         java.net.SocketAddress socketAddress)
        Formats SocketAddress as text.
        Parameters:
        buffer - The target buffer to append.
        socketAddress - The SocketAddress to append to buffer.
        Since:
        5.0
      • getCanonicalLocalHostName

        public static java.lang.String getCanonicalLocalHostName()
        Gets the canonical name of the local host, a fully qualified domain name.

        This can be "localhost" or a fully qualified domain name like "host.docker.internal".

        Returns:
        the canonical name of the local host.
        Since:
        5.0