/** * Create an IPv6 address from its String representation. For example * "1234:5678:abcd:0000:9876:3210:ffff:ffff" or "2001::ff" or even "::". * IPv4-Mapped IPv6 addresses such as "::ffff:123.456.123.456" are also * supported. * * @param string string representation * @return IPv6 address */ public IPv6Address fromString(String string) { if (string == null) { throw new IllegalArgumentException("can not parse [null]"); } final String withoutScope = removeScope(string); final String withoutIPv4MappedNotation = rewriteIPv4MappedNotation(withoutScope); final String longNotation = expandShortNotation(withoutIPv4MappedNotation); final long[] longs = tryParseStringArrayIntoLongArray(string, longNotation); return mergeLongArrayIntoIPv6Address(longs); }
/** * Create an IPv6 address from its String representation. For example * "1234:5678:abcd:0000:9876:3210:ffff:ffff" or "2001::ff" or even "::". * IPv4-Mapped IPv6 addresses such as "::ffff:123.456.123.456" are also * supported. * * @param string string representation * @return IPv6 address */ public IPv6Address fromString(String string) { if (string == null) { throw new IllegalArgumentException("can not parse [null]"); } final String withoutScope = removeScope(string); final String withoutIPv4MappedNotation = rewriteIPv4MappedNotation(withoutScope); final String longNotation = expandShortNotation(withoutIPv4MappedNotation); final long[] longs = tryParseStringArrayIntoLongArray(string, longNotation); return mergeLongArrayIntoIPv6Address(longs); }