2.17.2: 2011-06-17

net.sf.basedb.util.overview
Class Failure

java.lang.Object
  extended by net.sf.basedb.util.overview.Failure

public class Failure
extends Object

Holds information about a failed validation. Note that all rules are always validated. Use a ValidationOptions object to keep track of which validators that should be ignored, generate warnings or errors.

NOTE! The implementation of the equals(Object) method of this object is a bit unorthodox. Two failures are considered equal if they have the same validator but different nodes referencing the same item with the same descriptor. Two failures on the same node are never equal. This allows us to filter out duplicate failures that happens because there can be several ways to reach a certain item (for example a reference sample that is used on all hybridizations).

Version:
2.2
Author:
Nicklas
See Also:
Validator, ValidationOptions, GenericOverview.getFailures(), GenericOverview.getValidationOptions()
Last modified
$Date: 2010-08-13 10:50:27 +0200 (Fri, 13 Aug 2010) $

Field Summary
private  Object descriptor
           
private  List<Fix> fixes
           
private  String message
           
private  Node node
           
private  Validator validator
           
 
Constructor Summary
Failure(Validator validator, Node node)
          Create a new validation failure.
Failure(Validator validator, Node node, String message)
          Create a new validation failure with a detailed message.
Failure(Validator validator, Node node, String message, Fix... fixes)
          Create a new validation failure with a detailed message and a list of suggested fixes.
 
Method Summary
 void addFix(Fix fix)
          Add a suggested fix to this failure.
 boolean equals(Object o)
          One failure is the same as another if they have the same validator but different nodes referencing the same item with equal descriptors.
 Object getDescriptor()
           
 List<Fix> getFixes()
          Get a list of suggested fixes.
 String getMessage()
          Get a message explaining the failure.
 Node getNode()
          Get the node that failed validation.
 Validator getValidator()
          Get the validation rule that failed.
 int hashCode()
           
 void setDescriptor(Object descriptor)
          Set a descriptor on this failure.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

validator

private Validator validator

node

private Node node

message

private String message

fixes

private List<Fix> fixes

descriptor

private Object descriptor
Constructor Detail

Failure

public Failure(Validator validator,
               Node node)
Create a new validation failure.

Parameters:
validator - The validation rule that fails
node - The node that contains the failure

Failure

public Failure(Validator validator,
               Node node,
               String message)
Create a new validation failure with a detailed message.

Parameters:
validator - The validation rule that fails
node - The node that contains the failure
message - A detailed message about the failue, if null the Validator.getFailureSummary() is used

Failure

public Failure(Validator validator,
               Node node,
               String message,
               Fix... fixes)
Create a new validation failure with a detailed message and a list of suggested fixes.

Parameters:
validator - The validation rule that fails
node - The node that contains the failure
message - A detailed message about the failue, if null the Validator.getFailureSummary() is used
fixes - A list of suggested fixes
Method Detail

setDescriptor

public void setDescriptor(Object descriptor)
Set a descriptor on this failure. This affects the equals(Object) method, since the descriptor must be equal for two failures to be equal.

NOTE! The main reason for this property is that we need to discriminate between failures on different sub-arrays on hybridizations.

Parameters:
descriptor - Any object
Since:
2.6

getDescriptor

public Object getDescriptor()
Returns:
The descriptor
Since:
2.6
See Also:
setDescriptor(Object)

getValidator

public Validator getValidator()
Get the validation rule that failed.


getNode

public Node getNode()
Get the node that failed validation.


getMessage

public String getMessage()
Get a message explaining the failure.


getFixes

public List<Fix> getFixes()
Get a list of suggested fixes.

Returns:
A list of suggested fixes, or null if there are none

addFix

public void addFix(Fix fix)
Add a suggested fix to this failure.

Parameters:
fix - The fix to add.

toString

public String toString()
Overrides:
toString in class Object

equals

public boolean equals(Object o)
One failure is the same as another if they have the same validator but different nodes referencing the same item with equal descriptors.

Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

2.17.2: 2011-06-17