/** * Validates the given Object. * * @param object the Object to validate * @param context the ValidationContext * @throws ValidationException if the given String is not matched by the regular expression * pattern */ public void validate(final Object object, final ValidationContext context) throws ValidationException { if (object == null) { if (!_nillable) { String err = resourceBundle.getString("patternValidator.error.cannot.validate.null.object"); throw new ValidationException(err); } return; } validate(object.toString(), context); }
/** * Sets the regular expression to validate against. Deprecated since * Castor 1.1, supports only one pattern to preserve old behavior. Use * {@link #addPattern(String)}. * * @param pattern * the regular expression to use when validating * @deprecated since Castor 1.1, use {@link #addPattern(String)} */ public void setPattern(final String pattern) { clearPatterns(); addPattern(pattern); } // -- setPattern
/** * Initializes the regular expression validator. * * @param context the ValidationContext */ private void initEvaluator(final ValidationContext context) { _regex = context.getInternalContext().getRegExpEvaluator(); if (_regex == null && hasPattern()) { throw new IllegalStateException( resourceBundle.getString("patternValidator.error.exception.noPatterns")); } }
/** * Validates the given Object. * * @param object * the Object to validate * @param context * the ValidationContext * @throws ValidationException * if the given String is not matched by the regular expression * pattern */ public void validate(final Object object, final ValidationContext context) throws ValidationException { if (object == null) { if (!_nillable) { String err = "PatternValidator cannot validate a null object."; throw new ValidationException(err); } return; } validate(object.toString(), context); } // -- validate
/** * Validates the given Object. * * @param b * the boolean to validate * @param context * the ValidationContext * @throws ValidationException if the object fails validation. */ public void validate(final boolean b, final ValidationContext context) throws ValidationException { if (_useFixed && b != _fixed) { String err = "boolean " + b + " is not equal to the fixed value: " + _fixed; throw new ValidationException(err); } if (hasPattern()) { super.validate(new Boolean(b).toString(), context); } } //-- validate
/** * Validates the given Object. * * @param b the boolean to validate * @param context the ValidationContext * @throws ValidationException if the object fails validation. */ public void validate(final boolean b, final ValidationContext context) throws ValidationException { if (_useFixed && b != _fixed) { String err = "boolean " + b + " is not equal to the fixed value: " + _fixed; throw new ValidationException(err); } if (hasPattern()) { super.validate(String.valueOf(b), context); } } // -- validate
super.validate(Long.toString(value), context);
super.validate(value.toString(), context);
super.validate(value.toString(), context);
super.validate(Long.toString(value), context);
super.validate(Byte.toString(b), context);
super.validate(Short.toString(s), context);
super.validate(Integer.toString(i), context);
super.validate(Byte.toString(b), context);
super.validate(Long.toString(value), context);
super.validate(Integer.toString(i), context);
super.validate(Long.toString(i), context);
super.validate(Short.toString(s), context);