edu.nrao.sss.validation
Class ValidationFailure

java.lang.Object
  extended by edu.nrao.sss.validation.ValidationFailure

public class ValidationFailure
extends Object

Information about the failure of an attempt to validate an object.

Version Info:

$Revision: 370 $
$Date: 2007-02-20 15:35:20 -0700 (Tue, 20 Feb 2007) $
$Author: dharland $

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

Constructor Summary
ValidationFailure()
          Creates a new instance.
ValidationFailure(String displayMessage, String debugMessage, FailureSeverity severity, Object validationTarget, String nameOfValidator)
          Deprecated. 
ValidationFailure(String displayMessage, String debugMessage, FailureSeverity severity, Object validationTarget, String nameOfValidator, String nameOfTest)
          Creates a new instance with the given properties.
 
Method Summary
 String getDebugMessage()
          Returns the technical message of this failure.
 String getDisplayMessage()
          Returns a message suitable for display to a user.
 String getNameOfTest()
          Returns the name of the test that triggered this failure.
 String getNameOfValidator()
          Returns the name of the validator that triggered this failure.
 FailureSeverity getSeverity()
          Returns the severity of this failure.
 Object getValidationTarget()
          Returns the object that failed this validation.
 boolean isDisplayable()
          Returns true if this message is suitable for display to a user.
 void setDebugMessage(String newMessage)
          Sets a technical message for this failure.
 void setDisplayMessage(String newMessage)
          Sets a message suitable for display to a user.
 void setNameOfTest(String newName)
          Sets the name of the test that triggered this failure.
 void setNameOfValidator(String newName)
          Sets the name of the validator that triggered this failure.
 void setSeverity(FailureSeverity newSeverity)
          Sets the severity of this failure.
 void setValidationTarget(Object newTarget)
          Sets the object that failed this validation.
static ValidationFailure wrongObjectType(String validatorName, Object target, String expectedType)
          Creates a new failure instance for validators that receive unexpected target types.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ValidationFailure

public ValidationFailure()
Creates a new instance.


ValidationFailure

public ValidationFailure(String displayMessage,
                         String debugMessage,
                         FailureSeverity severity,
                         Object validationTarget,
                         String nameOfValidator,
                         String nameOfTest)
Creates a new instance with the given properties.


ValidationFailure

@Deprecated
public ValidationFailure(String displayMessage,
                                    String debugMessage,
                                    FailureSeverity severity,
                                    Object validationTarget,
                                    String nameOfValidator)
Deprecated. 

Method Detail

setDebugMessage

public void setDebugMessage(String newMessage)
Sets a technical message for this failure.

Parameters:
newMessage - a technical message for this failure.

getDebugMessage

public String getDebugMessage()
Returns the technical message of this failure.

Returns:
the technical message of this failure.

setDisplayMessage

public void setDisplayMessage(String newMessage)
Sets a message suitable for display to a user.

Parameters:
newMessage - a displayable message for this failure.

getDisplayMessage

public String getDisplayMessage()
Returns a message suitable for display to a user.

Returns:
a displayable message for this failure.

isDisplayable

public boolean isDisplayable()
Returns true if this message is suitable for display to a user.

Returns:
true if this message is suitable for display to a user.

setNameOfValidator

public void setNameOfValidator(String newName)
Sets the name of the validator that triggered this failure.

Parameters:
newName - the name of the validator that triggered this failure.

getNameOfValidator

public String getNameOfValidator()
Returns the name of the validator that triggered this failure.

Returns:
the name of the validator that triggered this failure.

getNameOfTest

public String getNameOfTest()
Returns the name of the test that triggered this failure.

Returns:
the name of the test that triggered this failure.

setNameOfTest

public void setNameOfTest(String newName)
Sets the name of the test that triggered this failure.

Parameters:
newName - the name of the test that triggered this failure.

setSeverity

public void setSeverity(FailureSeverity newSeverity)
Sets the severity of this failure.

Parameters:
newSeverity - the severity of this failure.

getSeverity

public FailureSeverity getSeverity()
Returns the severity of this failure.

Returns:
the severity of this failure.

setValidationTarget

public void setValidationTarget(Object newTarget)
Sets the object that failed this validation.

Parameters:
newTarget - the object that failed this validation.

getValidationTarget

public Object getValidationTarget()
Returns the object that failed this validation.

Returns:
the object that failed this validation.

wrongObjectType

public static ValidationFailure wrongObjectType(String validatorName,
                                                Object target,
                                                String expectedType)
Creates a new failure instance for validators that receive unexpected target types.

Parameters:
validatorName - the name of the validator for which this failure is being made.
target - the object being validated.
expectedType - the type of object the validator expected.
Returns:
a new validation failure.


Copyright © 2009. All Rights Reserved.