當前位置: 首頁>>代碼示例>>Java>>正文


Java ADMValidator.isUrl方法代碼示例

本文整理匯總了Java中org.oscm.validator.ADMValidator.isUrl方法的典型用法代碼示例。如果您正苦於以下問題:Java ADMValidator.isUrl方法的具體用法?Java ADMValidator.isUrl怎麽用?Java ADMValidator.isUrl使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.oscm.validator.ADMValidator的用法示例。


在下文中一共展示了ADMValidator.isUrl方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: validate

import org.oscm.validator.ADMValidator; //導入方法依賴的package包/類
/**
 * Validates that the given value is an URL
 * 
 * @param context
 *            FacesContext for the request we are processing
 * @param component
 *            UIComponent we are checking for correctness
 * @param value
 *            the value to validate
 * @throws ValidatorException
 *             if validation fails
 */
public void validate(FacesContext facesContext, UIComponent component,
        Object value) throws ValidatorException {
    if (value == null) {
        return;
    }
    String str = value.toString();
    if (str.length() == 0) {
        return;
    }

    if (ADMValidator.isUrl(str)) {
        return;
    }
    Object[] args = null;
    String label = JSFUtils.getLabel(component);
    if (label != null) {
        args = new Object[] { label };
    }
    ValidationException e = new ValidationException(
            ValidationException.ReasonEnum.URL, label, null);
    String text = JSFUtils.getText(e.getMessageKey(), args, facesContext);
    throw new ValidatorException(new FacesMessage(
            FacesMessage.SEVERITY_ERROR, text, null));
}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:37,代碼來源:UrlValidator.java

示例2: validateImprint

import org.oscm.validator.ADMValidator; //導入方法依賴的package包/類
public void validateImprint(final FacesContext context,
        final UIComponent component, final Object valueObj) {

    // skip if no value
    if (valueObj == null) {
        return;
    }
    String value = valueObj.toString();
    if (value.length() == 0) {
        return;
    }

    // the imprint value must contain a valid URL or a default text
    if (ADMValidator.isUrl(value)) {
        return;
    }
    if (checkIfDefaultText(value)) {
        return;
    }

    // validation failed
    throw constructValidatorException(context, component);
}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:24,代碼來源:TranslationBean.java

示例3: validateUrl

import org.oscm.validator.ADMValidator; //導入方法依賴的package包/類
private static void validateUrl(ConfigurationKey key, String value) {
    if (ADMValidator.isUrl(value)) {
        return;
    }
    throw new RuntimeException("The url format of " + key.getKeyName()
            + " must be valid.");
}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:8,代碼來源:ConfigurationSettingsValidator.java

示例4: validate

import org.oscm.validator.ADMValidator; //導入方法依賴的package包/類
/**
 * Validates that the given value is a relative URL
 * 
 * @param context
 *            FacesContext for the request we are processing
 * @param component
 *            UIComponent we are checking for correctness
 * @param value
 *            the value to validate
 * @throws ValidatorException
 *             if validation fails
 */
public void validate(FacesContext facesContext, UIComponent component,
        Object value) throws ValidatorException {
    if (value == null) {
        return;
    }
    String str = value.toString();
    if (str.length() == 0) {
        return;
    }

    // a relative URL must start with a "/"
    if (str.startsWith("/")) {
        // create a absolute URL to check all the other URL rules
        str = "http://xy".concat(str);
        if (ADMValidator.isUrl(str)) {
            return;
        }
    }

    Object[] args = null;
    String label = JSFUtils.getLabel(component);
    if (label != null) {
        args = new Object[] { label };
    }
    ValidationException e = new ValidationException(
            ValidationException.ReasonEnum.RELATIVE_URL, label, null);
    String text = JSFUtils.getText(e.getMessageKey(), args, facesContext);
    throw new ValidatorException(new FacesMessage(
            FacesMessage.SEVERITY_ERROR, text, null));
}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:43,代碼來源:RelUrlValidator.java


注:本文中的org.oscm.validator.ADMValidator.isUrl方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。