Class IPv6Utils


  • public class IPv6Utils
    extends java.lang.Object

    IPv6 utilities.

    For the moment, it only contains function to canonicalize IPv6 address into RFC 5952 form.

    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String canonize​(java.lang.String ipv6Address)
      Convert IPv6 address into RFC 5952 form.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • canonize

        public static java.lang.String canonize​(java.lang.String ipv6Address)

        Convert IPv6 address into RFC 5952 form. E.g. 2001:db8:0:1:0:0:0:1 -> 2001:db8:0:1::1

        Method is null safe, and if IPv4 address or host name is passed to the method it is returned without any processing.

        Method also supports IPv4 in IPv6 (e.g. 0:0:0:0:0:ffff:192.0.2.1 -> ::ffff:192.0.2.1), and zone ID (e.g. fe80:0:0:0:f0f0:c0c0:1919:1234%4 -> fe80::f0f0:c0c0:1919:1234%4).

        Input that looks like an IPv6 address but is malformed, such as one with more than 8 groups or a group with more than 4 significant characters, is returned without any processing. The result is otherwise undefined if an invalid IPv6 address is passed in as input.

        Parameters:
        ipv6Address - String representing valid IPv6 address.
        Returns:
        String representing IPv6 in canonical form, or the unchanged input if it is null, not an IPv6 address or malformed.