jef.dna.util
Class ValidationExceptionHelper

java.lang.Object
  extended by jef.dna.util.ValidationExceptionHelper

public class ValidationExceptionHelper
extends java.lang.Object

This helper class is available starting from every ValidationExceptionAncestor instance, and is meant for abstracting the developer from all the reflection releted programming issues necessary for dealing with such exception instances.

Author:
Francesco Russo frusso@cs.unibo.it

Constructor Summary
ValidationExceptionHelper()
          Creates a new instance of ValidationExceptionHelper
 
Method Summary
<T> void
correctAttribute(T param)
          Replaces the value of the attribute over which the validation process failed with the expected right one passed as parameter.
<T> T
getActualValue(T param)
          This method returns the actual value of the parameter over which the validation process failed.
 void setException(ValidationExceptionAncestor e)
          Sets the ValidationExceptionAncestor subclass handled by the current ValidationExceptionHelper.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ValidationExceptionHelper

public ValidationExceptionHelper()
Creates a new instance of ValidationExceptionHelper

Method Detail

setException

public void setException(ValidationExceptionAncestor e)
Sets the ValidationExceptionAncestor subclass handled by the current ValidationExceptionHelper.

Parameters:
e - The exception to be handled

correctAttribute

public <T> void correctAttribute(T param)
Replaces the value of the attribute over which the validation process failed with the expected right one passed as parameter. This method can be invoked with every actual parameter thanks to the use of generics.

Parameters:
param - The actual parameter which can be either a primitive or reference type

getActualValue

public <T> T getActualValue(T param)
This method returns the actual value of the parameter over which the validation process failed.

Parameters:
param - A variable of the same type (either primitive or reference) of the one we are requesting the actual value
Returns:
T The actual value of the wrong parameter