edu.nrao.sss.validation
Interface Validator

All Known Implementing Classes:
AbstractValidator

public interface Validator

A validator of objects. The job of this validator is to look at target objects and see if they are suitable for using for a particular purpose.

Clients do not typically fetch a validator and use it to validate their target objects. Instead they call the validate method of ValidationManager.

Version Info:

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

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

Method Summary
 String getName()
          Returns the name of this validator.
 ValidationPurpose getPurpose()
          Returns the purpose for which this validator was most recently run.
 Object getTarget()
          Returns the object most recently subject to validation by this validator.
 void setManager(ValidationManager newManager)
          Sets the manager for which this validator is performing its duties.
 void stopTestingAfterFirstFailure(boolean stop)
          Tells this validator whether it should run all validations or stop after the first validation that fails.
 List<ValidationFailure> validate(Object target, ValidationPurpose purpose)
          Validates target for use for the given purpose.
 

Method Detail

validate

List<ValidationFailure> validate(Object target,
                                 ValidationPurpose purpose)
Validates target for use for the given purpose.

Parameters:
target - the object to be validated.
purpose - the reason for the validation.
Returns:
a list of failures encountered during validation. If there were no failures, an empty list is returned.

setManager

void setManager(ValidationManager newManager)
Sets the manager for which this validator is performing its duties. It is not necessary for this validator to work for any manager; therefore null is an acceptable value for newManager.

The main use made by this validator of its manager is to request validators for the component objects held by the target object of this validator.

Parameters:
newManager - the manager for which this validator is performing its duties.

stopTestingAfterFirstFailure

void stopTestingAfterFirstFailure(boolean stop)
Tells this validator whether it should run all validations or stop after the first validation that fails. The concrete implementations of this interface are free to choose their default behavior here.

Parameters:
stop - if true this validator will stop running its validations after the first one fails.

getName

String getName()
Returns the name of this validator. A common construct is for a validator to return its fully qualified class name.

Returns:
the name of this validator.

getTarget

Object getTarget()
Returns the object most recently subject to validation by this validator.

Returns:
the object most recently subject to validation by this validator. If this validator has not yet been used, the return value will be null.

getPurpose

ValidationPurpose getPurpose()
Returns the purpose for which this validator was most recently run.

Returns:
the purpose for which this validator was most recently run.


Copyright © 2009. All Rights Reserved.