Package com.unboundid.util.args
Class URLArgumentValueValidator
- java.lang.Object
-
- com.unboundid.util.args.ArgumentValueValidator
-
- com.unboundid.util.args.URLArgumentValueValidator
-
- All Implemented Interfaces:
java.io.Serializable
@NotMutable @ThreadSafety(level=COMPLETELY_THREADSAFE) public final class URLArgumentValueValidator extends ArgumentValueValidator implements java.io.Serializable
This class provides an implementation of an argument value validator that is expected to be used with a string argument and ensures that all values for the argument are valid URLs. It can optionally restrict the URLs to a specified set of schemes.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description URLArgumentValueValidator(java.lang.String... allowedSchemes)Creates a new instance of this URL argument value validator that will accept values that are URLs with any of the specified schemes.URLArgumentValueValidator(java.util.Collection<java.lang.String> allowedSchemes)Creates a new instance of this URL argument value validator that will accept values that are URLs with any of the specified schemes.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Set<java.lang.String>getAllowedSchemes()Retrieves the names of the schemes for the URLs that will be accepted.java.lang.StringtoString()Retrieves a string representation of this argument value validator.voidtoString(java.lang.StringBuilder buffer)Appends a string representation of this argument value validator to the provided buffer.voidvalidateArgumentValue(Argument argument, java.lang.String valueString)Examines the value(s) assigned to the provided argument to determine whether they are acceptable.
-
-
-
Constructor Detail
-
URLArgumentValueValidator
public URLArgumentValueValidator(java.lang.String... allowedSchemes)
Creates a new instance of this URL argument value validator that will accept values that are URLs with any of the specified schemes.- Parameters:
allowedSchemes- The names of the schemes for the URLs that will be accepted. It may benullor empty if any scheme will be accepted.
-
URLArgumentValueValidator
public URLArgumentValueValidator(java.util.Collection<java.lang.String> allowedSchemes)
Creates a new instance of this URL argument value validator that will accept values that are URLs with any of the specified schemes.- Parameters:
allowedSchemes- The names of the schemes for the URLs that will be accepted. It may benullor empty if any scheme will be accepted.
-
-
Method Detail
-
getAllowedSchemes
public java.util.Set<java.lang.String> getAllowedSchemes()
Retrieves the names of the schemes for the URLs that will be accepted.- Returns:
- The names of the schemes for the URLs that will be accepted, or an empty set if URLs will be allowed to have any scheme.
-
validateArgumentValue
public void validateArgumentValue(Argument argument, java.lang.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.
-
toString
public java.lang.String toString()
Retrieves a string representation of this argument value validator.- Overrides:
toStringin classjava.lang.Object- Returns:
- A string representation of this argument value validator.
-
toString
public void toString(java.lang.StringBuilder buffer)
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.
-
-