net.sf.doolin.gui.validation
Class SimpleValidator<B>

java.lang.Object
  extended by net.sf.doolin.gui.validation.AbstractValidator<B>
      extended by net.sf.doolin.gui.validation.SimpleValidator<B>
Type Parameters:
B - Type of object for the view
All Implemented Interfaces:
GUIValidator<B>

public class SimpleValidator<B>
extends AbstractValidator<B>

Validator based on textual declarations.

Each validation has the following format:

 <validation> := <context>=<validators>
 
 <context> := <key>:<property>[:<name>]
 <validators> := Comma-separated list of <validator>
 
where: validator keys are used to identify ObjectValidator instances. Predefined ones are: It is possible to declare new keys using the setObjectValidators(Map) method or the objectValidators property.

Author:
Damien Coraboeuf

Nested Class Summary
protected  class SimpleValidator.SimpleValidation
          Validation support that operates as a link to an ObjectValidator instance.
 
Constructor Summary
SimpleValidator()
           
 
Method Summary
 Map<String,ObjectValidator> getObjectValidators()
          Gets the map between the validator keys and the ObjectValidator instances.
 List<String> getValidations()
          Gets the validations.
 void init()
          Initialises the object validators.
 void setObjectValidators(Map<String,ObjectValidator> objectValidators)
          Sets the map between the validator keys and the ObjectValidator instances.
 void setValidations(List<String> validations)
          Sets the validations.
 void subscribe(SubscriberValidator validator, B model, Runnable runnable)
          Subscribes the validator to the model changes.
protected  void validate(GUIValidation validationResult, B bean)
          Validate.
 
Methods inherited from class net.sf.doolin.gui.validation.AbstractValidator
getMsgMandatoryKey, isNotBlank, isNotNull, setMsgMandatoryKey, validate, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleValidator

public SimpleValidator()
Method Detail

getObjectValidators

public Map<String,ObjectValidator> getObjectValidators()
Gets the map between the validator keys and the ObjectValidator instances.

Returns:
Validators

getValidations

public List<String> getValidations()
Gets the validations.

Returns:
the validations

init

@PostConstruct
public void init()
          throws IllegalArgumentException
Initialises the object validators.

Throws:
IllegalArgumentException - If there is problem of parsing

setObjectValidators

public void setObjectValidators(Map<String,ObjectValidator> objectValidators)
Sets the map between the validator keys and the ObjectValidator instances.

Parameters:
objectValidators - Validators

setValidations

public void setValidations(List<String> validations)
Sets the validations.

Parameters:
validations - the new validations

subscribe

public void subscribe(SubscriberValidator validator,
                      B model,
                      Runnable runnable)
Description copied from interface: GUIValidator
Subscribes the validator to the model changes.

Parameters:
validator - Subscription validator
model - Model to subscribe to
runnable - Task to subscribe

validate

protected void validate(GUIValidation validationResult,
                        B bean)
Validate..

Specified by:
validate in class AbstractValidator<B>
Parameters:
validationResult - the validation result
bean - the bean


Copyright © 2011. All Rights Reserved.