Example usage for java.util.regex Pattern matches

List of usage examples for java.util.regex Pattern matches

Introduction

In this page you can find the example usage for java.util.regex Pattern matches.

Prototype

public static boolean matches(String regex, CharSequence input) 

Source Link

Document

Compiles the given regular expression and attempts to match the given input against it.

Usage

From source file:de.blizzy.documentr.validation.MacroNameValidator.java

@Override
public boolean isValid(String value, ConstraintValidatorContext context) {
    if (StringUtils.isBlank(value)) {
        return true;
    }//from   w w w. j  ava2 s  .co m

    return Pattern.matches("^" + DocumentrConstants.MACRO_NAME_PATTERN + "$", value); //$NON-NLS-1$ //$NON-NLS-2$
}

From source file:de.blizzy.documentr.validation.BranchNameValidator.java

@Override
public boolean isValid(String value, ConstraintValidatorContext context) {
    if (StringUtils.isBlank(value)) {
        return true;
    }//from  w  w  w  .  ja  v  a 2 s .c  o  m

    return Pattern.matches("^" + DocumentrConstants.BRANCH_NAME_PATTERN + "$", value); //$NON-NLS-1$ //$NON-NLS-2$
}

From source file:de.blizzy.documentr.validation.ProjectNameValidator.java

@Override
public boolean isValid(String value, ConstraintValidatorContext context) {
    if (StringUtils.isBlank(value)) {
        return true;
    }/*w  w  w . j a  v a 2  s  . c  om*/

    return Pattern.matches("^" + DocumentrConstants.PROJECT_NAME_PATTERN + "$", value); //$NON-NLS-1$ //$NON-NLS-2$
}

From source file:br.gov.frameworkdemoiselle.util.contrib.Strings.java

public static boolean isResourceBundleKeyFormat(final String key) {
    return Pattern.matches("^\\{(.+)\\}$", key == null ? "" : key);
}

From source file:de.blizzy.documentr.validation.BranchNameBlacklistValidator.java

@Override
public boolean isValid(String value, ConstraintValidatorContext context) {
    if (StringUtils.isBlank(value)) {
        return true;
    }//from www. j a va2  s  .c o  m

    return !Pattern.matches("^" + DocumentrConstants.BRANCH_NAMES_BLACKLIST_PATTERN + "$", value); //$NON-NLS-1$ //$NON-NLS-2$
}

From source file:de.blizzy.documentr.validation.ProjectNameBlacklistValidator.java

@Override
public boolean isValid(String value, ConstraintValidatorContext context) {
    if (StringUtils.isBlank(value)) {
        return true;
    }/*ww  w  .  j a  va 2s  .c  o  m*/

    return !Pattern.matches("^" + DocumentrConstants.PROJECT_NAMES_BLACKLIST_PATTERN + "$", value); //$NON-NLS-1$ //$NON-NLS-2$
}

From source file:org.training.storefront.forms.validation.EmailValidator.java

@Override
public void validate(final Object object, final Errors errors) {
    final UpdateEmailForm updateEmailForm = (UpdateEmailForm) object;
    final String email = updateEmailForm.getEmail();
    final String chkEmail = updateEmailForm.getChkEmail();
    final String password = updateEmailForm.getPassword();

    if (StringUtils.isEmpty(email)) {
        errors.rejectValue("email", "profile.email.invalid");
    } else if (StringUtils.length(email) > 255 || !Pattern.matches(EMAIL_REGEX, email)) {
        errors.rejectValue("email", "profile.email.invalid");
    }/*  ww  w . ja  va 2  s  . com*/

    if (StringUtils.isEmpty(chkEmail)) {
        errors.rejectValue("chkEmail", "profile.checkEmail.invalid");
    }

    if (StringUtils.isEmpty(password)) {
        errors.rejectValue("password", "profile.pwd.invalid");
    }
}

From source file:com.adobe.acs.commons.version.impl.EvolutionConfig.java

public boolean handleProperty(String name) {
    for (String entry : ignoreProperties) {
        if (Pattern.matches(entry, name)) {
            return false;
        }//from  w  ww  .  j  av  a2 s  .  co m
    }
    return true;
}

From source file:com.expedia.weather.model.validator.ForecastFormValidator.java

@Override
public void validate(Object target, Errors errors) {
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "zip", ForecastFormValidator.ERR_CODE_ZIP_INVALID,
            ForecastFormValidator.ERR_CODE_ZIP_NOTFOUND);
    if (!errors.hasErrors()) {
        ForecastForm form = (ForecastForm) target;
        if (!Pattern.matches(ForecastFormValidator.US_ZIPCODE_REGEXP, form.getZip())) {
            errors.rejectValue("zip", ForecastFormValidator.ERR_CODE_ZIP_INVALID,
                    ForecastFormValidator.ERR_CODE_ZIP_INVALID);
        }/*from w  w w  .j ava 2 s . c  om*/
    }
}

From source file:info.archinnov.achilles.internal.validation.Validator.java

public static void validateRegExp(String arg, String regexp, String label) {
    validateNotBlank(arg, "The text value '%s' should not be blank", label);
    if (!Pattern.matches(regexp, arg)) {
        throw new AchillesException(format("The property '%s' should match the pattern '%s'", label, regexp));
    }/*w  ww.j a va 2  s. c  o  m*/
}