public class UrlValidator extends java.lang.Object
URL Validation routines.
Behavior of validation is modified by passing in options:Originally based in on php script by Debbie Dyer, validation.php v1.2b, Date: 03/07/02, http://javascript.internet.com. However, this validation now bears little resemblance to the php original.
   Example of usage:
   Construct a UrlValidator with valid schemes of "http", and "https".
    String[] schemes = {"http","https"}.
    UrlValidator urlValidator = new UrlValidator(schemes);
    if (urlValidator.isValid("ftp://foo.bar.com/")) {
       System.out.println("url is valid");
    } else {
       System.out.println("url is invalid");
    }
    prints "url is invalid"
   If instead the default constructor is used.
    UrlValidator urlValidator = new UrlValidator();
    if (urlValidator.isValid("ftp://foo.bar.com/")) {
       System.out.println("url is valid");
    } else {
       System.out.println("url is invalid");
    }
   prints out "url is valid"
  
 | Modifiers | Name | Description | 
|---|---|---|
| static long | ALLOW_2_SLASHES | Allow two slashes in the path component of the URL. | 
| static long | ALLOW_ALL_SCHEMES | Allows all validly formatted schemes to pass validation instead of supplying a set of valid schemes. | 
| static long | NO_FRAGMENTS | Enabling this options disallows any URL fragments. | 
| Constructor and description | 
|---|
| UrlValidator
                                ()Create a UrlValidator with default properties. | 
| UrlValidator
                                (java.lang.String[] schemes)Behavior of validation is modified by passing in several strings options: | 
| UrlValidator
                                (long options)Initialize a UrlValidator with the given validation options. | 
| UrlValidator
                                (java.lang.String[] schemes, long options)Behavior of validation is modified by passing in options: | 
| UrlValidator
                                (RegexValidator authorityValidator, long options)Initialize a UrlValidator with the given validation options. | 
| UrlValidator
                                (java.lang.String[] schemes, RegexValidator authorityValidator, long options)Customizable constructor. | 
| Type | Name and description | 
|---|---|
| protected int | countToken(java.lang.String token, java.lang.String target)Returns the number of times the token appears in the target. | 
| static UrlValidator | getInstance()Returns the singleton instance of this class with default schemes and options. | 
| boolean | isValid(java.lang.String value) | 
| protected boolean | isValidAuthority(java.lang.String authority)Returns true if the authority is properly formatted. | 
| protected boolean | isValidFragment(java.lang.String fragment)Returns true if the given fragment is null or fragments are allowed. | 
| protected boolean | isValidPath(java.lang.String path)Returns true if the path is valid. | 
| protected boolean | isValidQuery(java.lang.String query)Returns true if the query is null or it's a properly formatted query string. | 
| protected boolean | isValidScheme(java.lang.String scheme)Validate scheme. | 
| Methods inherited from class | Name | 
|---|---|
| class java.lang.Object | java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() | 
Allow two slashes in the path component of the URL.
Allows all validly formatted schemes to pass validation instead of supplying a set of valid schemes.
Enabling this options disallows any URL fragments.
Create a UrlValidator with default properties.
Behavior of validation is modified by passing in several strings options:
schemes -  Pass in one or more url schemes to consider valid, passing in
        a null will default to "http,https,ftp" being valid.
        If a non-null schemes is specified then all valid schemes must
        be specified. Setting the ALLOW_ALL_SCHEMES option will
        ignore the contents of schemes.Initialize a UrlValidator with the given validation options.
options -  The options should be set using the public constants declared in
 this class.  To set multiple options you simply add them together.  For example,
 ALLOW_2_SLASHES + NO_FRAGMENTS enables both of those options.Behavior of validation is modified by passing in options:
schemes -  The set of valid schemes.options -  The options should be set using the public constants declared in
 this class.  To set multiple options you simply add them together.  For example,
 ALLOW_2_SLASHES + NO_FRAGMENTS enables both of those options.Initialize a UrlValidator with the given validation options.
authorityValidator -  Regular expression validator used to validate the authority partoptions -  Validation options. Set using the public constants of this class.
 To set multiple options, simply add them together:
 ALLOW_2_SLASHES + NO_FRAGMENTS
Customizable constructor. Validation behavior is modifed by passing in options.
schemes -  the set of valid schemesauthorityValidator -  Regular expression validator used to validate the authority partoptions -  Validation options. Set using the public constants of this class.
 To set multiple options, simply add them together:
 ALLOW_2_SLASHES + NO_FRAGMENTS
Returns the number of times the token appears in the target.
token -  Token value to be counted.target -  Target value to count tokens in.Returns the singleton instance of this class with default schemes and options.
Checks if a field has a valid url address.
value -  The value validation is being performed on.  A null
 value is considered invalid. Returns true if the authority is properly formatted.  An authority is the combination
 of hostname and port.  A null authority value is considered invalid.
     
authority -  Authority value to validate.Returns true if the given fragment is null or fragments are allowed.
fragment -  Fragment value to validate. Returns true if the path is valid.  A null value is considered invalid.
     
path -  Path value to validate.Returns true if the query is null or it's a properly formatted query string.
query -  Query value to validate.Validate scheme. If schemes[] was initialized to a non null, then only those scheme's are allowed. Note this is slightly different than for the constructor.
scheme -  The scheme to validate.  A null value is considered
 invalid.