Top Description Fields Constructors Methods
org.apache.tomcat.util.net

public Class IPv6Utils

extends Object
Class Inheritance

IPv6 utilities.

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

Field Summary

Modifier and TypeField and Description
private static final int
private static final int

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static String

Returns:

String representing IPv6 in canonical form.
canonize
(String
String representing valid IPv6 address.
ipv6Address
)

Convert IPv6 address into RFC 5952 form.

pack-priv static boolean

Returns:

true, if input string contains only hex digits and at least two colons, before '.' or '%' character
mayBeIPv6Address
(String
Any string or null
input
)

Heuristic check if string might be an IPv6 address.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

MAX_GROUP_LENGTHback to summary
private static final int MAX_GROUP_LENGTH
MAX_NUMBER_OF_GROUPSback to summary
private static final int MAX_NUMBER_OF_GROUPS

Constructor Detail

IPv6Utilsback to summary
public IPv6Utils()

Method Detail

canonizeback to summary
public static String canonize(String ipv6Address) throws IllegalArgumentException

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).

The behaviour of this method is undefined if an invalid IPv6 address is passed in as input.

Parameters
ipv6Address:String

String representing valid IPv6 address.

Returns:String

String representing IPv6 in canonical form.

Exceptions
IllegalArgumentException:
if IPv6 format is unacceptable.
mayBeIPv6Addressback to summary
pack-priv static boolean mayBeIPv6Address(String input)

Heuristic check if string might be an IPv6 address.

Parameters
input:String

Any string or null

Returns:boolean

true, if input string contains only hex digits and at least two colons, before '.' or '%' character