org.iscreen
Interface ValidationService

All Known Implementing Classes:
BaseValidationService, DefaultValidationService, ValidationServiceGroup, ValidationServiceWrapper

public interface ValidationService

This interface represents the main entry point for performing validations.

A note about exceptions:
The interface is designed to be used so that checked exceptions are thrown when a validation failure (or warning) occurs. The debate about checked versus unchecked exceptions is a long and heated one, but it is the author's opinion that checked exceptions (in this case, at least) are the more appropriate approach. However, realizing that a framework may be used in different ways, and not wishing to force a particular opinion on developers, the validateObject() methods were added to support unchecked exceptions. However, there is a known issue with these methods and the unchecked exception this they throw: these interfaces are mere copies on top of the checked exceptions calls (i.e. convenience methods), and as such, will lose the original root exception (and, hence, the original stack trace). Under normal circumstances, this isn't an issue (since your users shouldn't care), but it does cause issues for developers trying to debug. Hence, the "contained" checked exception can be retrieved from the unchecked exception's API for debugging purposes.

Author:
Shellman, Dan

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.
 

Method Detail

validate

void validate(java.lang.Object obj)
              throws ValidationException
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.

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

validate

void validate(java.lang.Object obj,
              java.util.Locale locale)
              throws ValidationException
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.

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

void validateObject(java.lang.Object obj)
Identical to validate() except that it throws the unchecked exception ObjectValidationException instead of a checked exception.

Parameters:
obj - The object (usually a JavaBean) to validate.
Throws:
ObjectValidationException - The exception containing any validation failures.

validateObject

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.

Parameters:
obj - The object (usually a JavaBean) to validate.
locale - The locale used for failure message generation.
Throws:
ObjectValidationException - The exception containing any validation failures.

getServiceName

java.lang.String getServiceName()
The service name (unique id) of the service. This is the fully qualified name of the Validation Set that this service represents.

Returns:
Returns the unique service name/id of this service.

getDocumentation

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

Returns:
Returns an iterator of Strings representing documentation.