org.iscreen
Class ValidationException

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by org.iscreen.ValidationException
All Implemented Interfaces:
java.io.Serializable

public class ValidationException
extends java.lang.Exception

When a validation failure occurs, eventually a ValidationException is thrown to the caller. This is a checked exception that should be handled by the caller. The exception contains the list of ValidationFailures that represent the validations that have failed. Ultimately, the failures should be used to notify the end user (or system).

Author:
Shellman, Dan
See Also:
Serialized Form

Field Summary
protected  java.util.List failures
           
protected  java.util.Map namedFailures
           
 
Constructor Summary
ValidationException()
          Default constructor with no pre-defined validation failures.
ValidationException(java.util.List validationFailures)
          Constructor with pre-defined validation failures.
ValidationException(java.util.List validationFailures, java.util.List validationWarnings)
          Constructor with pre-defined validation failures and warnings.
 
Method Summary
 void addFailure(ValidationFailure failure)
          Add a failure to this exception.
 void addValidationException(ValidationException e)
           
 java.util.List getFailureMessages()
          Retrieves the list of failure messages (List of String objects).
 java.util.List getFailures()
          Retrieves the List of ValidationFailures associated with this exception that represent the failures.
 java.util.List getFailures(int minimumSeverity)
          Retrieves the failures that meet the minimum severity level passed in.
 java.util.List getFailures(int minimumSeverity, int maximumSeverity)
          Retrieves the failures that meet the minimum severity level and maximum severity level passed in (inclusive).
 java.util.List getNamedFailures(java.lang.String validatorName)
          Retrieves the List of failures (and warnings) that are associated with a particular "name." The name is defined in the configuration, and is associated with a particular use of a validator.
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

failures

protected java.util.List failures

namedFailures

protected java.util.Map namedFailures
Constructor Detail

ValidationException

public ValidationException()
Default constructor with no pre-defined validation failures.


ValidationException

public ValidationException(java.util.List validationFailures)
Constructor with pre-defined validation failures.

Parameters:
validationFailures - The List of ValidationFailures for this exception.

ValidationException

public ValidationException(java.util.List validationFailures,
                           java.util.List validationWarnings)
Constructor with pre-defined validation failures and warnings. Each List must contain ValidationFailure objects.

Parameters:
validationFailures - The List of failures for this exception.
validationWarnings - The List of warnings for this exception.
Method Detail

addFailure

public void addFailure(ValidationFailure failure)
Add a failure to this exception. This failure will be appended to the end of the internal list of failures.

Parameters:
failure - The ValidationFailure to add to this exception.

getFailures

public java.util.List getFailures()
Retrieves the List of ValidationFailures associated with this exception that represent the failures.

Returns:
Returns a List of ValidationFailures.

getFailures

public java.util.List getFailures(int minimumSeverity)
Retrieves the failures that meet the minimum severity level passed in. This method is used to retrieve, for example, any warnings: getFailures( ValidationFailure.WARNING );

Parameters:
minimumSeverity - The minimal severity level.
Returns:
Returns a list of ValidationFailure objects whose severity level is equal to or greater than minimumSeverity.

getFailures

public java.util.List getFailures(int minimumSeverity,
                                  int maximumSeverity)
Retrieves the failures that meet the minimum severity level and maximum severity level passed in (inclusive). This method is used to retrieve failures with a severity within a particular range, for example, any warnings: getFailures( 0, ValidationFailure.WARNING );

Parameters:
minimumSeverity - The minimal severity level (inclusive).
maximumSeverity - The maximum severity level (inclusive).
Returns:
Returns a list of ValidationFailure objects whose severity level is equal to or greater than minimumSeverity and less than or equal to maximumSeverity.

getNamedFailures

public java.util.List getNamedFailures(java.lang.String validatorName)
Retrieves the List of failures (and warnings) that are associated with a particular "name." The name is defined in the configuration, and is associated with a particular use of a validator. This is interesting when mapping back to some form of presentation layer.

Parameters:
validatorName - The name to find failures against.
Returns:
Returns a List of ValidationFailure objects (or an empty List if there are none associated with the given name). Will not return null.

getFailureMessages

public java.util.List getFailureMessages()
Retrieves the list of failure messages (List of String objects).

Returns:
Returns the List of failure messages (as Strings).

addValidationException

public void addValidationException(ValidationException e)