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

java.lang.Object
  extended by edu.nrao.sss.validation.Validation<T>
      extended by edu.nrao.sss.validation.DataNotEnteredValidation<T>

public abstract class DataNotEnteredValidation<T>
extends Validation<T>

A validation for empty or unitialized properties. Subclasses of this validation need only a constructor and an implementation of getCurrentValue().

Version Info:

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

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

Field Summary
protected  String defaultValue
          See constructor documentation.
protected  String fieldName
          See constructor documentation.
protected  String genericTargetName
          See constructor documentation.
protected  String specificTargetName
          Instead of a generic concept name, implementing classes can use the name of a specific instance.
 
Fields inherited from class edu.nrao.sss.validation.Validation
container, purpose, severity
 
Constructor Summary
protected DataNotEnteredValidation(AbstractValidator<T> validationContainer, ValidationPurpose reasonForValidation, String genericNameOfTarget, String nameOfField, String defaultValueOfField)
          Helps create an instance.
 
Method Summary
protected  String debugMessage()
          Returns a technical message to be used if this validation fails.
protected  String displayMessage()
          Returns a user-friendly message to be used if this validation fails.
protected abstract  String getCurrentValue()
          The current value of the targeted field, in text form.
protected  boolean passesTest()
          Test is passed if current value is non-null, non-empty, and not in its default state.
 
Methods inherited from class edu.nrao.sss.validation.Validation
getName, run
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

genericTargetName

protected String genericTargetName
See constructor documentation.


specificTargetName

protected String specificTargetName
Instead of a generic concept name, implementing classes can use the name of a specific instance. If this value is non-null, it will be used in the messages in place of genericTargetName.

For instance, a generic name might be "user", whereas the target of this validation is the specific user "Mother Theresa". In this situation, the implementing class would preferentially use "Mother Theresa", which will make the resulting failure message easier to understand for a human user. The best time to set this value is in the getCurrentValue() method.


fieldName

protected String fieldName
See constructor documentation.


defaultValue

protected String defaultValue
See constructor documentation.

Constructor Detail

DataNotEnteredValidation

protected DataNotEnteredValidation(AbstractValidator<T> validationContainer,
                                   ValidationPurpose reasonForValidation,
                                   String genericNameOfTarget,
                                   String nameOfField,
                                   String defaultValueOfField)
Helps create an instance.

Parameters:
validationContainer - The validator that will use this validation.
reasonForValidation - The reason we are doing this validation.
genericNameOfTarget - A generic name for the target of the validation. Examples: "User", "Project", "Scheduling Block".
nameOfField - The name of the field for which data was not entered. A name that is suitable for presentation to a human user is suggested. Examples: "social security number", "last name", "LST".
defaultValueOfField - The value this field has if it has not been changed from its default state. This validation will fail if the current value of the field being checked is null, the empty string (""), or this default value.
Method Detail

getCurrentValue

protected abstract String getCurrentValue()
The current value of the targeted field, in text form. If you wish to use a "specific name" (eg, "Scan Abc" as opposed to "the scan") in your message, set specificTargetName in this method.


passesTest

protected boolean passesTest()
Test is passed if current value is non-null, non-empty, and not in its default state.

Specified by:
passesTest in class Validation<T>
Returns:
true if the target object passes this validation.

displayMessage

protected String displayMessage()
Description copied from class: Validation
Returns a user-friendly message to be used if this validation fails.

Specified by:
displayMessage in class Validation<T>
Returns:
a user-friendly message to be used if this validation fails.

debugMessage

protected String debugMessage()
Description copied from class: Validation
Returns a technical message to be used if this validation fails.

Specified by:
debugMessage in class Validation<T>
Returns:
a technical message to be used if this validation fails.


Copyright © 2009. All Rights Reserved.