public class InetAddressValidator
extends java.lang.Object
implements java.io.Serializable
InetAddress validation and conversion routines (java.net.InetAddress).
This class provides methods to validate a candidate IP address.
This class is a Singleton; you can retrieve the instance via the getInstance() method.
| Modifier and Type | Field and Description |
|---|---|
private static java.lang.String |
IPV4_REGEX |
private RegexValidator |
ipv4Validator
IPv4 RegexValidator
|
private static long |
serialVersionUID |
private static InetAddressValidator |
VALIDATOR
Singleton instance of this class.
|
| Constructor and Description |
|---|
InetAddressValidator() |
| Modifier and Type | Method and Description |
|---|---|
static InetAddressValidator |
getInstance()
Returns the singleton instance of this validator.
|
boolean |
isValid(java.lang.String inetAddress)
Checks if the specified string is a valid IP address.
|
boolean |
isValidInet4Address(java.lang.String inet4Address)
Validates an IPv4 address.
|
boolean |
isValidInet6Address(java.lang.String inet6Address)
Validates an IPv6 address.
|
private static final long serialVersionUID
private static final java.lang.String IPV4_REGEX
private static final InetAddressValidator VALIDATOR
private final RegexValidator ipv4Validator
public static InetAddressValidator getInstance()
public boolean isValid(java.lang.String inetAddress)
inetAddress - the string to validatepublic boolean isValidInet4Address(java.lang.String inet4Address)
inet4Address - the IPv4 address to validatepublic boolean isValidInet6Address(java.lang.String inet6Address)
inet6Address - the IPv6 address to validate