org.iscreen
Class ValidationServiceWrapper

java.lang.Object
  extended by org.iscreen.ValidationServiceWrapper
All Implemented Interfaces:
ValidationService

public class ValidationServiceWrapper
extends java.lang.Object
implements ValidationService

This wrapper around a ValidationService is itself a ValidationService implementation. However, it can be used as a wrapper that takes a validation factory and the validation set name, bypassing the need to call the factory's getValidationService() method.

Author:
Shellman, Dan

Constructor Summary
ValidationServiceWrapper(java.lang.Object beanToValidate)
          This constructor uses all defaults.
ValidationServiceWrapper(ValidationFactoryConfig config, java.lang.String validationSetName)
          Construct the wrapper with a factory config and the ValidationSet name (the name of the service).
ValidationServiceWrapper(ValidationFactoryConfig config, java.lang.String metaPropertyName, java.lang.String metaValue)
          Construct the wrapper with a factory config and meta data about the validation service.
ValidationServiceWrapper(ValidationFactory factory, java.lang.String validationSetName)
          Construct the wrapper with an existing factory and the ValidationSet name (the name of the service).
ValidationServiceWrapper(ValidationFactory factory, java.lang.String metaPropertyName, java.lang.String metaValue)
          Construct the wrapper with an existing factory and meta data about the validation service.
 
Method Summary
 DocumentationIterator getDocumentation()
          Retrieves an iterator of String values representing the documentation configured for this validation service (the underlying validation set).
 java.lang.String getServiceName()
          The service name (unique id) of the service.
 void validate(java.lang.Object obj)
          Called to validate an object (typically a JavaBean).
 void validate(java.lang.Object obj, java.util.Locale locale)
          Called to validate an object (typically a JavaBean).
 void validateObject(java.lang.Object obj)
          Identical to validate() except that it throws the unchecked exception ObjectValidationException instead of a checked exception.
 void validateObject(java.lang.Object obj, java.util.Locale locale)
          Identical to validate() except that it throws the unchecked exception ObjectValidationException instead of a checked exception.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ValidationServiceWrapper

public ValidationServiceWrapper(java.lang.Object beanToValidate)
This constructor uses all defaults. It assumes the default XML factory (i.e. OGNL XML), as well as the default locale and no services. It also assumes that the bean passed in has been associated with a validation set using the default meta tag: com.some.bean
Note that the bean passed in isn't actually being validated. You still need to call the appropriate validate() method to validate it.

Parameters:
beanToValidate - The bean to be validated.

ValidationServiceWrapper

public ValidationServiceWrapper(ValidationFactory factory,
                                java.lang.String validationSetName)
Construct the wrapper with an existing factory and the ValidationSet name (the name of the service).

Parameters:
factory - The factory containing the validation service
validationSetName - The fully qualified name of the validation set

ValidationServiceWrapper

public ValidationServiceWrapper(ValidationFactory factory,
                                java.lang.String metaPropertyName,
                                java.lang.String metaValue)
Construct the wrapper with an existing factory and meta data about the validation service.
A typical use of this is to get a validation service based upon the bean to be validated's class name:
new ValidationServiceWrapper( factory, "className", bean.getClass().getName() );

Parameters:
factory - The config of the validation factory
metaPropertyName - The property name of the meta data
metaValue - The value of the meta data.

ValidationServiceWrapper

public ValidationServiceWrapper(ValidationFactoryConfig config,
                                java.lang.String validationSetName)
Construct the wrapper with a factory config and the ValidationSet name (the name of the service). The factory config should be completely configured prior to constructing this wrapper.

Parameters:
config - The config of the validation factory
validationSetName - The fully qualified name of the validation set

ValidationServiceWrapper

public ValidationServiceWrapper(ValidationFactoryConfig config,
                                java.lang.String metaPropertyName,
                                java.lang.String metaValue)
Construct the wrapper with a factory config and meta data about the validation service. The factory config should be completely configured prior to constructing this wrapper.
A typical use of this is to get a validation service based upon the bean to be validated's class name:
new ValidationServiceWrapper( config, "className", bean.getClass().getName() );

Parameters:
config - The config of the validation factory
metaPropertyName - The property name of the meta data
metaValue - The value of the meta data.
Method Detail

validate

public void validate(java.lang.Object obj)
              throws ValidationException
Description copied from interface: ValidationService
Called to validate an object (typically a JavaBean). If the object passes validation, nothing occurs (there should be no side-effects). If one or more Validators find one or more validation failures, then an exception will be thrown containing all validations failures found.

Specified by:
validate in interface ValidationService
Parameters:
obj - The object (usually a JavaBean) to validate.
Throws:
ValidationException - The exception containing any validation failures.

validate

public void validate(java.lang.Object obj,
                     java.util.Locale locale)
              throws ValidationException
Description copied from interface: ValidationService
Called to validate an object (typically a JavaBean). If the object passes validation, nothing occurs (there should be no side-effects). If one or more Validators find one or more validation failures, then an exception will be thrown containing all validations failures found.

Specified by:
validate in interface ValidationService
Parameters:
obj - The object (usually a JavaBean) to validate.
locale - The locale used for failure message generation.
Throws:
ValidationException - The exception containing any validation failures.

validateObject

public void validateObject(java.lang.Object obj)
Description copied from interface: ValidationService
Identical to validate() except that it throws the unchecked exception ObjectValidationException instead of a checked exception.

Specified by:
validateObject in interface ValidationService
Parameters:
obj - The object (usually a JavaBean) to validate.

validateObject

public void validateObject(java.lang.Object obj,
                           java.util.Locale locale)
Description copied from interface: ValidationService
Identical to validate() except that it throws the unchecked exception ObjectValidationException instead of a checked exception.

Specified by:
validateObject in interface ValidationService
Parameters:
obj - The object (usually a JavaBean) to validate.
locale - The locale used for failure message generation.

getServiceName

public java.lang.String getServiceName()
Description copied from interface: ValidationService
The service name (unique id) of the service. This is the fully qualified name of the Validation Set that this service represents.

Specified by:
getServiceName in interface ValidationService
Returns:
Returns the unique service name/id of this service.

getDocumentation

public DocumentationIterator getDocumentation()
Retrieves an iterator of String values representing the documentation configured for this validation service (the underlying validation set).

Specified by:
getDocumentation in interface ValidationService
Returns:
Returns an iterator of Strings representing documentation.