Class SubnetUtils6

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      class  SubnetUtils6.SubnetInfo
      Contains IPv6 subnet summary information.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.math.BigInteger address  
      private java.math.BigInteger high  
      private static java.math.BigInteger MAX_VALUE  
      private static int NBITS  
      private java.math.BigInteger network  
      private static java.lang.String PARSE_FAIL  
      private int prefixLength  
      private static java.math.BigInteger TWO  
    • Constructor Summary

      Constructors 
      Constructor Description
      SubnetUtils6​(java.lang.String cidrNotation)
      Constructs an instance from a CIDR-notation string, e.g., "2001:db8::1/64".
      SubnetUtils6​(java.lang.String address, int prefixLength)
      Constructs an instance from an IPv6 address and prefix length.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private static java.lang.String format​(java.math.BigInteger addr)
      Formats a BigInteger as an IPv6 address string using InetAddress.getHostAddress().
      SubnetUtils6.SubnetInfo getInfo()
      Gets a SubnetUtils6.SubnetInfo instance that contains subnet-specific statistics.
      private static byte[] toByteArray16​(java.math.BigInteger value)
      Converts a BigInteger to a 16-byte array, padding with leading zeros if necessary.
      private static byte[] toBytes​(java.lang.String address)
      Parses an IPv6 address string to a byte array.
      java.lang.String toString()
      Returns a summary of this subnet for debugging.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • TWO

        private static final java.math.BigInteger TWO
      • MAX_VALUE

        private static final java.math.BigInteger MAX_VALUE
      • address

        private final java.math.BigInteger address
      • high

        private final java.math.BigInteger high
      • network

        private final java.math.BigInteger network
      • prefixLength

        private final int prefixLength
    • Constructor Detail

      • SubnetUtils6

        public SubnetUtils6​(java.lang.String cidrNotation)
        Constructs an instance from a CIDR-notation string, e.g., "2001:db8::1/64".
        Parameters:
        cidrNotation - a CIDR-notation string, e.g., "2001:db8::1/64".
        Throws:
        java.lang.IllegalArgumentException - if the parameter is invalid.
      • SubnetUtils6

        public SubnetUtils6​(java.lang.String address,
                            int prefixLength)
        Constructs an instance from an IPv6 address and prefix length.
        Parameters:
        address - an IPv6 address, e.g., "2001:db8::1".
        prefixLength - the prefix length (0-128).
        Throws:
        java.lang.IllegalArgumentException - if the parameters are invalid.
    • Method Detail

      • format

        private static java.lang.String format​(java.math.BigInteger addr)
        Formats a BigInteger as an IPv6 address string using InetAddress.getHostAddress().
        Parameters:
        addr - the address as a BigInteger.
        Returns:
        the formatted IPv6 address string.
        See Also:
        RFC 5952
      • toByteArray16

        private static byte[] toByteArray16​(java.math.BigInteger value)
        Converts a BigInteger to a 16-byte array, padding with leading zeros if necessary.
        Parameters:
        value - the BigInteger to convert.
        Returns:
        a 16-byte array.
      • toBytes

        private static byte[] toBytes​(java.lang.String address)
        Parses an IPv6 address string to a byte array.
        Parameters:
        address - the IPv6 address string.
        Returns:
        the 16-byte representation.
        Throws:
        java.lang.IllegalArgumentException - if the address cannot be parsed.