nl.knowlogy.validation
Class ClassValidatorImpl

java.lang.Object
  extended by nl.knowlogy.validation.ClassValidatorImpl
All Implemented Interfaces:
ClassValidator, ClassMetadata

public class ClassValidatorImpl
extends Object
implements ClassValidator, ClassMetadata

Author:
Robert Hofstra, Knowlogy

Constructor Summary
ClassValidatorImpl(Class clazz)
           
 
Method Summary
 void add(PropertyValidation propertyValidation)
           
 void add(PropertyValidation propertyValidation, PropertyMetadataSuplier propertyMetadataSuplier)
           
 void addPropertyToGroups(String groupNames, String propertyName)
           
 Class getClazz()
          Returns clazz that can be validated by this validator.
 List getPropertyMetadata()
           
 PropertyMetadata getPropertyMetadata(String propertyName)
           Returns PropertyMetadata for the given propertyName.
protected  Object getValue(Object toValidate, String propertyName)
           
 void validate(Object toValidate)
          Validates the object, if an error is signaled a Validation exception is thrown.
 void validate(Object toValidate, Messages messages)
          Validates the whole object.
 void validateGroup(Object toValidate, String groupName, Messages errors)
          Validates only the properties, which are contained in the group.
 void validateProperties(Object toValidate, List propertyNames, Messages messages)
          Validates only the properties, supplied in de propertyNames list, of the object toValidate.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClassValidatorImpl

public ClassValidatorImpl(Class clazz)
Method Detail

getClazz

public Class getClazz()
Description copied from interface: ClassValidator
Returns clazz that can be validated by this validator. Subclasses of this class can also be validated by this class.

Specified by:
getClazz in interface ClassValidator
Returns:
class

getPropertyMetadata

public PropertyMetadata getPropertyMetadata(String propertyName)
Description copied from interface: ClassMetadata

Returns PropertyMetadata for the given propertyName. If no property with propertyName exist null is returned.

Specified by:
getPropertyMetadata in interface ClassMetadata
Parameters:
propertyName - name of the property
Returns:
PropertyMetadata for the given propertyName. If no property with propertyName exist null is returned.
See Also:
PropertyMetadata

getPropertyMetadata

public List getPropertyMetadata()

add

public void add(PropertyValidation propertyValidation)
Specified by:
add in interface ClassValidator

add

public void add(PropertyValidation propertyValidation,
                PropertyMetadataSuplier propertyMetadataSuplier)

addPropertyToGroups

public void addPropertyToGroups(String groupNames,
                                String propertyName)
Specified by:
addPropertyToGroups in interface ClassValidator

validate

public void validate(Object toValidate)
Description copied from interface: ClassValidator
Validates the object, if an error is signaled a Validation exception is thrown.

Specified by:
validate in interface ClassValidator
Parameters:
toValidate - object to validate

getValue

protected Object getValue(Object toValidate,
                          String propertyName)

validate

public void validate(Object toValidate,
                     Messages messages)
Description copied from interface: ClassValidator
Validates the whole object. In case of validation errors, validation messages are added to the messages.

Specified by:
validate in interface ClassValidator
Parameters:
toValidate - object to validate
messages - container to which validate messages are added.

validateGroup

public void validateGroup(Object toValidate,
                          String groupName,
                          Messages errors)
Description copied from interface: ClassValidator
Validates only the properties, which are contained in the group. This group is identified by groupname. In case of validation errors, validation messages are added to the messages.

Specified by:
validateGroup in interface ClassValidator
Parameters:
toValidate - object which group is validated.
groupName - name of the group.
errors - container to which validate messages are added.

validateProperties

public void validateProperties(Object toValidate,
                               List propertyNames,
                               Messages messages)
Description copied from interface: ClassValidator
Validates only the properties, supplied in de propertyNames list, of the object toValidate. In case of validation errors, validation messages are added to the messages.

Specified by:
validateProperties in interface ClassValidator
Parameters:
toValidate - object which properties are validated
propertyNames - List of names (String) of the properties which are validated
messages - container to which validate messages are added.


Copyright © 2007. All Rights Reserved.