Example usage for org.apache.commons.validator.routines UrlValidator getInstance

List of usage examples for org.apache.commons.validator.routines UrlValidator getInstance

Introduction

In this page you can find the example usage for org.apache.commons.validator.routines UrlValidator getInstance.

Prototype

public static UrlValidator getInstance() 

Source Link

Document

Returns the singleton instance of this class with default schemes and options.

Usage

From source file:org.lirazs.gbackbone.validation.client.rule.UrlRule.java

@Override
public boolean isValid(final String url, String attribute) {
    String[] schemes = ruleAnnotation.schemes();
    long options = ruleAnnotation.allowFragments() ? 0 : UrlValidator.NO_FRAGMENTS;

    UrlValidator urlValidator = schemes != null && schemes.length > 0 ? new UrlValidator(schemes, options)
            : UrlValidator.getInstance();

    return urlValidator.isValid(url);
}

From source file:org.p_vcd.ui.VcdDialog.java

private boolean validateCurrentStep() {
    if (currentStep == 1) {
        List<VideoDatabase> selectedRefDbs = getSelectedRefDbs();
        if (selectedRefDbs.size() == 0) {
            SwingUtil.showMessage("Must select a reference database");
            return false;
        }//from   w ww.  jav  a 2 s  .  c om
    } else if (currentStep == 2) {
        if (radio_queryFile.isSelected()) {
            if (queryFile == null || !queryFile.isFile()) {
                SwingUtil.showMessage("Invalid query file");
                return false;
            }
        } else if (radio_queryUrl.isSelected()) {
            try {
                String value = txt_queryUrl.getText();
                if (UrlValidator.getInstance().isValid(value))
                    queryUrl = new URL(value);
                else
                    throw new Exception();
            } catch (Throwable t) {
                SwingUtil.showMessage("Invalid URL");
                txt_queryUrl.requestFocus();
                queryUrl = null;
                return false;
            }
        } else if (radio_queryDb.isSelected()) {
            if (queryDb == null) {
                SwingUtil.showMessage("Must select a query database");
                comboBox_queryDb.requestFocus();
                return false;
            }
        } else {
            SwingUtil.showMessage("Must select the query type: File, URL or Database.");
            return false;
        }
    } else if (currentStep == 3) {
        if (!radio_searchByGlobal.isSelected() && !radio_searchByLocal.isSelected()) {
            SwingUtil.showMessage("Must select the search type.");
            return false;
        }
    }
    return true;
}