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(OgnlRoot 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  OgnlRoot constructRoot(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.
protected abstract  ValidatorWrapper getNextValidator()
          Retrieves the "next" Validator in the set of Validators that this validation service is configured to use.
 java.lang.String getServiceName()
          The service name (unique id) of the service.
protected abstract  void resetValidatorIteration()
          Resets the iteration of Validators using the getNextValidator() method.
 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).
 
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.

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.

getNextValidator

protected abstract ValidatorWrapper getNextValidator()
Retrieves the "next" Validator in the set of Validators that this validation service is configured to use. If there are no more Validators, then this method should return null. It should return the first Validator after a call to resetValidatorIteration().

Returns:
Returns the next ValidatorWrapper in the set of validators.

resetValidatorIteration

protected abstract void resetValidatorIteration()
Resets the iteration of Validators using the getNextValidator() method.


constructContext

protected DefaultValidatorContext constructContext(OgnlRoot 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 OgnlRoot that the context needs.
locale - The locale to use in generating error messages.
Returns:
Returns a constructed and configured DefaultValidatorContext.

constructRoot

protected OgnlRoot constructRoot(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 OgnlRoot fully configured.