List of usage examples for org.springframework.validation Validator supports
boolean supports(Class<?> clazz);
From source file:com.acc.validator.CompositeValidator.java
@Override public void validate(final Object object, final Errors errors) { for (final Validator v : validators) { if (v.supports(object.getClass())) { v.validate(object, errors);// ww w.jav a2 s. c o m } } }
From source file:com.acc.validator.CompositeValidator.java
@Override public boolean supports(final Class clazz) { for (final Validator v : validators) { if (v.supports(clazz)) { return true; }// w w w.j ava 2 s.com } return false; }
From source file:biz.deinum.multitenant.validation.CompositeValidator.java
/** * Validate the specified object using the validator registered for the object's class. *//*from w w w.j ava 2 s .c o m*/ public void validate(final Object target, final Errors errors) { for (final Validator v : this.validators) { if (v.supports(target.getClass())) { v.validate(target, errors); } } }
From source file:biz.deinum.multitenant.validation.CompositeValidator.java
/** * Will return true if this class is in the specified map. *//* w w w .j a v a 2 s .com*/ @SuppressWarnings("rawtypes") public boolean supports(final Class clazz) { for (final Validator v : this.validators) { if (v.supports(clazz)) { return true; } } return false; }
From source file:org.springmodules.validation.validator.CompoundValidator.java
/** * Validates the given object. All internal validators that support the given object class * will perform the actual validation./* w w w . ja v a 2s . c om*/ * * @param obj The validated object. * @param errors A registry where validation errors are registered. * @see Validator#validate(Object, org.springframework.validation.Errors) */ public void validate(Object obj, Errors errors) { for (Iterator i = validators.iterator(); i.hasNext();) { Validator validator = (Validator) i.next(); if (validator.supports(obj.getClass())) { validator.validate(obj, errors); } } }
From source file:org.springmodules.validation.validator.CompoundValidator.java
/** * Returns whether this validator supports the given class. In practice this validator * supports the given class only if any of its internal validators support it. * * @param clazz The class to be validated. * @return Whether this validator supports the given class. * @see Validator#supports(Class)/* w ww .j av a 2 s . co m*/ */ public boolean supports(Class clazz) { for (Iterator i = validators.iterator(); i.hasNext();) { Validator validator = (Validator) i.next(); if (validator.supports(clazz)) { return true; } } return false; }
From source file:org.agatom.springatom.cmp.wizards.core.CreateObjectWizardProcessor.java
@Override public void setLocalValidator(final Validator localValidator) { final Class<?> contextObjectClass = this.getContextObjectClass(); if (!localValidator.supports(contextObjectClass)) { throw new IllegalArgumentException(String.format( "Validator [%s] does not support form object class [%s]", localValidator, contextObjectClass)); }//from w w w. ja v a2 s . c om super.setLocalValidator(localValidator); }
From source file:com.hihsoft.baseclass.web.controller.BaseController.java
/** * Request. Spring MVCBind?,??/*from ww w .ja v a2 s .c om*/ * * @return * @see #preBind(HttpServletRequest,Object,ServletRequestDataBinder) */ protected BindingResult bindObject(final HttpServletRequest request, final Object command) throws Exception { Assert.notNull(command); // Binder final ServletRequestDataBinder binder = createBinder(request, command); // ?binder?,?binder? preBind(request, command, binder); // binder.bind(request); // final Validator[] validators = getValidators(); if (validators != null) { for (final Validator validator : validators) { if (validator.supports(command.getClass())) { ValidationUtils.invokeValidator(validator, command, binder.getBindingResult()); } } } return binder.getBindingResult(); }
From source file:org.codehaus.groovy.grails.web.binding.GrailsDataBinder.java
private static void initializeFromWebRequest(GrailsDataBinder binder, GrailsWebRequest webRequest) { if (webRequest == null) { return;//from ww w . j ava 2 s .c o m } binder.setGrailsApplication(webRequest.getAttributes().getGrailsApplication()); if (webRequest.getApplicationContext() != null && webRequest.getApplicationContext().containsBean("dataBindingValidator")) { Validator validator = webRequest.getApplicationContext().getBean("dataBindingValidator", Validator.class); if (binder.getTarget() != null && validator.supports(binder.getTarget().getClass())) { binder.setValidator(validator); } } }