public boolean isValid()

in src/main/java/org/apache/commons/validator/routines/UrlValidator.java [298:341]


    public boolean isValid(final String value) {
        if (value == null) {
            return false;
        }

        URI uri; // ensure value is a valid URI
        try {
            uri = new URI(value);
        } catch (final URISyntaxException e) {
            return false;
        }
        // OK, perform additional validation

        final String scheme = uri.getScheme();
        if (!isValidScheme(scheme)) {
            return false;
        }

        final String authority = uri.getRawAuthority();
        if ("file".equals(scheme) && (authority == null || authority.isEmpty())) {// Special case - file: allows an empty authority
            return true; // this is a local file - nothing more to do here
        }
        if ("file".equals(scheme) && authority != null && authority.contains(":")) {
            return false;
        }
        // Validate the authority
        if (!isValidAuthority(authority)) {
            return false;
        }

        if (!isValidPath(uri.getRawPath())) {
            return false;
        }

        if (!isValidQuery(uri.getRawQuery())) {
            return false;
        }

        if (!isValidFragment(uri.getRawFragment())) {
            return false;
        }

        return true;
    }