edu.nrao.sss.validation
Class Validation<T>

java.lang.Object
  extended by edu.nrao.sss.validation.Validation<T>
Direct Known Subclasses:
DataNotEnteredValidation

public abstract class Validation<T>
extends Object

An individual test run by a Validator. Instances of this class are not generally needed by clients who request validation, but are instead used by specific implementations of validators.

Version Info:

$Revision: 868 $
$Date: 2007-09-12 13:15:10 -0600 (Wed, 12 Sep 2007) $
$Author: dharland $

Since:
2007-02-05
Author:
David M. Harland

Field Summary
protected  AbstractValidator<T> container
          The validator of which this validation is a part.
protected  ValidationPurpose purpose
          The reason for doing this validation.
protected  FailureSeverity severity
          A measure of the consequences of failing this validation.
 
Constructor Summary
protected Validation(AbstractValidator<T> validationContainer, ValidationPurpose reasonForValidation)
          Helps create a new instance.
 
Method Summary
protected abstract  String debugMessage()
          Returns a technical message to be used if this validation fails.
protected abstract  String displayMessage()
          Returns a user-friendly message to be used if this validation fails.
protected  String getName()
          Returns the name of this test.
protected abstract  boolean passesTest()
          Returns true if the target object passes this validation.
protected  boolean run(List<ValidationFailure> failures)
          Runs this validation and places any failures in the given list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

container

protected AbstractValidator<T> container
The validator of which this validation is a part.


severity

protected FailureSeverity severity
A measure of the consequences of failing this validation.


purpose

protected ValidationPurpose purpose
The reason for doing this validation.

Constructor Detail

Validation

protected Validation(AbstractValidator<T> validationContainer,
                     ValidationPurpose reasonForValidation)
Helps create a new instance.

Parameters:
validationContainer - the validator that holds this validation.
reasonForValidation - the reason this validation is being performed.
Method Detail

run

protected boolean run(List<ValidationFailure> failures)
Runs this validation and places any failures in the given list.

Parameters:
failures - the destination for any failures encountered while running this validation.
Returns:
true if this validation was successful, false otherwise.

getName

protected String getName()
Returns the name of this test.

This default implementation returns the fully qualified class name of the validation class. Implementing subclasses may choose to override this default and use some other name.

Returns:
the name of this test.

passesTest

protected abstract boolean passesTest()
Returns true if the target object passes this validation.

Returns:
true if the target object passes this validation.

displayMessage

protected abstract String displayMessage()
Returns a user-friendly message to be used if this validation fails.

Returns:
a user-friendly message to be used if this validation fails.

debugMessage

protected abstract String debugMessage()
Returns a technical message to be used if this validation fails.

Returns:
a technical message to be used if this validation fails.


Copyright © 2009. All Rights Reserved.