Package com.unboundid.util.args
Class IPAddressArgumentValueValidator
java.lang.Object
com.unboundid.util.args.ArgumentValueValidator
com.unboundid.util.args.IPAddressArgumentValueValidator
- All Implemented Interfaces:
Serializable
@NotMutable
@ThreadSafety(level=COMPLETELY_THREADSAFE)
public final class IPAddressArgumentValueValidator
extends ArgumentValueValidator
implements Serializable
This class provides an implementation of an argument value validator that
ensures that values can be parsed as valid IPv4 or IPV6 addresses.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new IP address argument value validator that will accept both IPv4 and IPv6 addresses.IPAddressArgumentValueValidator(boolean acceptIPv4Addresses, boolean acceptIPv6Addresses) Creates a new IP address argument value validator that will accept both IPv4 and IPv6 addresses. -
Method Summary
Modifier and TypeMethodDescriptionbooleanIndicates whether to accept IPv4 addresses.booleanIndicates whether to accept IPv6 addresses.static booleanIndicates whether the provided string represents a valid IPv4 or IPv6 address.static booleanIndicates whether the provided string is a valid IPv4 address.static booleanIndicates whether the provided string is a valid IPv6 address.toString()Retrieves a string representation of this argument value validator.voidtoString(StringBuilder buffer) Appends a string representation of this argument value validator to the provided buffer.voidvalidateArgumentValue(Argument argument, String valueString) Examines the value(s) assigned to the provided argument to determine whether they are acceptable.
-
Constructor Details
-
IPAddressArgumentValueValidator
public IPAddressArgumentValueValidator()Creates a new IP address argument value validator that will accept both IPv4 and IPv6 addresses. -
IPAddressArgumentValueValidator
Creates a new IP address argument value validator that will accept both IPv4 and IPv6 addresses. At least one of theacceptIPv4AddressesandacceptIPv6Addressesarguments must have a value oftrue.- Parameters:
acceptIPv4Addresses- Indicates whether IPv4 addresses will be accepted. If this isfalse, then theacceptIPv6Addressesargument must betrue.acceptIPv6Addresses- Indicates whether IPv6 addresses will be accepted. If this isfalse, then theacceptIPv4Addressesargument must betrue.
-
-
Method Details
-
acceptIPv4Addresses
Indicates whether to accept IPv4 addresses.- Returns:
trueif IPv4 addresses should be accepted, orfalseif not.
-
acceptIPv6Addresses
Indicates whether to accept IPv6 addresses.- Returns:
trueif IPv6 addresses should be accepted, orfalseif not.
-
validateArgumentValue
public void validateArgumentValue(@NotNull Argument argument, @NotNull String valueString) throws ArgumentException Examines the value(s) assigned to the provided argument to determine whether they are acceptable.- Specified by:
validateArgumentValuein classArgumentValueValidator- Parameters:
argument- The argument to which the value is being provided.valueString- The string representation of the value to be validated. This value will have already passed any normal validation performed by the argument.- Throws:
ArgumentException- If the provided value is determined to be unacceptable.
-
isValidNumericIPAddress
Indicates whether the provided string represents a valid IPv4 or IPv6 address.- Parameters:
s- The string for which to make the determination.- Returns:
trueif the provided string represents a valid IPv4 or IPv6 address, orfalseif not.
-
isValidNumericIPv4Address
Indicates whether the provided string is a valid IPv4 address.- Parameters:
s- The string for which to make the determination.- Returns:
trueif the provided string represents a valid IPv4 address, orfalseif not.
-
isValidNumericIPv6Address
Indicates whether the provided string is a valid IPv6 address.- Parameters:
s- The string for which to make the determination.- Returns:
trueif the provided string represents a valid IPv6 address, orfalseif not.
-
toString
Retrieves a string representation of this argument value validator. -
toString
Appends a string representation of this argument value validator to the provided buffer.- Parameters:
buffer- The buffer to which the string representation should be appended.
-