Class InetAddressValidator
- java.lang.Object
-
- org.openstreetmap.josm.data.validation.routines.AbstractValidator
-
- org.openstreetmap.josm.data.validation.routines.InetAddressValidator
-
public class InetAddressValidator extends AbstractValidator
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.- Since:
- Validator 1.4
- Version:
- $Revision: 1741724 $
-
-
Field Summary
Fields Modifier and Type Field Description private static int
BASE_16
private static int
IPV4_MAX_OCTET_VALUE
private static java.lang.String
IPV4_REGEX
private RegexValidator
ipv4Validator
IPv4 RegexValidatorprivate static int
IPV6_MAX_HEX_DIGITS_PER_GROUP
private static int
IPV6_MAX_HEX_GROUPS
private static int
MAX_UNSIGNED_SHORT
private static InetAddressValidator
VALIDATOR
Singleton instance of this class.
-
Constructor Summary
Constructors Constructor Description InetAddressValidator()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static InetAddressValidator
getInstance()
Returns the singleton instance of this validator.java.lang.String
getValidatorName()
Returns the name of this validatorboolean
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.-
Methods inherited from class org.openstreetmap.josm.data.validation.routines.AbstractValidator
getErrorMessage, setErrorMessage
-
-
-
-
Field Detail
-
IPV4_MAX_OCTET_VALUE
private static final int IPV4_MAX_OCTET_VALUE
- See Also:
- Constant Field Values
-
MAX_UNSIGNED_SHORT
private static final int MAX_UNSIGNED_SHORT
- See Also:
- Constant Field Values
-
BASE_16
private static final int BASE_16
- See Also:
- Constant Field Values
-
IPV4_REGEX
private static final java.lang.String IPV4_REGEX
- See Also:
- Constant Field Values
-
IPV6_MAX_HEX_GROUPS
private static final int IPV6_MAX_HEX_GROUPS
- See Also:
- Constant Field Values
-
IPV6_MAX_HEX_DIGITS_PER_GROUP
private static final int IPV6_MAX_HEX_DIGITS_PER_GROUP
- See Also:
- Constant Field Values
-
VALIDATOR
private static final InetAddressValidator VALIDATOR
Singleton instance of this class.
-
ipv4Validator
private final RegexValidator ipv4Validator
IPv4 RegexValidator
-
-
Constructor Detail
-
InetAddressValidator
public InetAddressValidator()
-
-
Method Detail
-
getInstance
public static InetAddressValidator getInstance()
Returns the singleton instance of this validator.- Returns:
- the singleton instance of this validator
-
isValid
public boolean isValid(java.lang.String inetAddress)
Checks if the specified string is a valid IP address.- Specified by:
isValid
in classAbstractValidator
- Parameters:
inetAddress
- the string to validate- Returns:
- true if the string validates as an IP address
-
getValidatorName
public java.lang.String getValidatorName()
Description copied from class:AbstractValidator
Returns the name of this validator- Specified by:
getValidatorName
in classAbstractValidator
- Returns:
- the name of this validator
-
isValidInet4Address
public boolean isValidInet4Address(java.lang.String inet4Address)
Validates an IPv4 address. Returns true if valid.- Parameters:
inet4Address
- the IPv4 address to validate- Returns:
- true if the argument contains a valid IPv4 address
-
isValidInet6Address
public boolean isValidInet6Address(java.lang.String inet6Address)
Validates an IPv6 address. Returns true if valid.- Parameters:
inet6Address
- the IPv6 address to validate- Returns:
- true if the argument contains a valid IPv6 address
- Since:
- 1.4.1
-
-