|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.dpml.cli.validation.URLValidator
public class URLValidator
The URLValidator validates the string argument
values are URLs. If the value is a URL, the string value in
the List of values is replaced with the
URL instance.
URLs can also be validated based on their scheme by using
the setProtocol method, or by using the specified
constructor.
The following example shows how to limit the valid values
for the site argument to 'https' URLs.
...
ArgumentBuilder builder = new ArgumentBuilder();
Argument site =
builder.withName("site");
.withValidator(new URLValidator("https"));
| Constructor Summary | |
|---|---|
URLValidator()
Creates a URLValidator. |
|
URLValidator(String protocol)
Creates a URLValidator for the specified protocol. |
|
| Method Summary | |
|---|---|
String |
getProtocol()
Returns the protocol that must be used by a valid URL. |
void |
setProtocol(String protocol)
Specifies the protocol that a URL must have to be valid. |
void |
validate(List values)
Validate the list of values against the list of permitted values. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public URLValidator()
public URLValidator(String protocol)
protocol - the url protocol| Method Detail |
|---|
public void validate(List values)
throws InvalidArgumentException
values
List with the { java.net.URL} instance.
validate in interface Validatorvalues - the list of values to validate
InvalidArgumentException - if a value is invalidValidator.validate(java.util.List)public String getProtocol()
public void setProtocol(String protocol)
protocol - the protocol that a URL must have to be valid.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||