org.iscreen.impl
Class BaseValidationService

java.lang.Object
  extended by org.iscreen.impl.BaseValidationService
All Implemented Interfaces:
ValidationService
Direct Known Subclasses:
DefaultValidationService

public abstract class BaseValidationService
extends java.lang.Object
implements ValidationService

This is the base class implementation of the ValidationService interface.

Author:
Shellman, Dan

Field Summary
protected  java.util.Locale defaultLocale
           
protected  java.lang.String id
           
 
Constructor Summary
BaseValidationService(java.lang.String uniqueId, java.util.Locale locale)
          Constructor taking unique id.
 
Method Summary
protected  DefaultValidatorContext constructContext(ContextBean root, java.util.Locale locale)
          This can be over-written by sub-classes, but it's not really necessary, since this service requires a particular implementation of the ValidatorContext.
protected  ContextBean constructContextBean(java.lang.Object objToValidate)
          This can be over-written by sub-classes, but it's not really necessary, since this service requires an OGNL root object.
 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.
protected abstract  java.util.Iterator getWrapperIterator()
          Retrieves an Iterator that will iterate through the ValidatorWrapper instances contained by this 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
 

Field Detail

id

protected java.lang.String id

defaultLocale

protected java.util.Locale defaultLocale
Constructor Detail

BaseValidationService

public BaseValidationService(java.lang.String uniqueId,
                             java.util.Locale locale)
Constructor taking unique id. The unique id is required. In addition, the default locale is provided.

Parameters:
uniqueId - The unique id for this service.
locale - The default locale for this service.
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,
                           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.

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.

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.

getWrapperIterator

protected abstract java.util.Iterator getWrapperIterator()
Retrieves an Iterator that will iterate through the ValidatorWrapper instances contained by this service.

Returns:
Returns an Iterator of the contained ValidatorWrappers.

constructContext

protected DefaultValidatorContext constructContext(ContextBean root,
                                                   java.util.Locale locale)
This can be over-written by sub-classes, but it's not really necessary, since this service requires a particular implementation of the ValidatorContext.

Parameters:
root - The ContextBean that the context needs.
locale - The locale to use in generating error messages.
Returns:
Returns a constructed and configured DefaultValidatorContext.

constructContextBean

protected ContextBean constructContextBean(java.lang.Object objToValidate)
This can be over-written by sub-classes, but it's not really necessary, since this service requires an OGNL root object.

Returns:
Returns an instance of ContextBean fully configured.