multex
Class ReflectionCauseGetter

java.lang.Object
  |
  +--multex.ReflectionCauseGetter
All Implemented Interfaces:
CauseGetter

public class ReflectionCauseGetter
extends java.lang.Object
implements CauseGetter

Describes, how to get the causing exception of any non-MulTEx-exception in any JDK supporting reflection. Reflection was introduced in JDK 1.1. This is now the default CauseGetter used by class Failure to get the cause of a Throwable.

See Also:
for a consideration about future default use of it, Failure.setCauseGetter(CauseGetter)

Constructor Summary
ReflectionCauseGetter()
           
 
Method Summary
 java.lang.Throwable getCause(java.lang.Throwable i_throwable)
          Returns the cause of i_throwable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReflectionCauseGetter

public ReflectionCauseGetter()
Method Detail

getCause

public java.lang.Throwable getCause(java.lang.Throwable i_throwable)
Returns the cause of i_throwable. If i_throwable is one of the few JDK 1.1 exceptions with a cause getter (java.lang.reflect.InvocationTargetException, ExceptionInInitializerError, java.sql.SQLWarning, or java.sql.SQLException) then uses its legacy cause getter method explicitly. Otherwise uses reflection in order to try to get a causing Throwable. Firstly tries the method getCause(), which is the standard cause getter from JDK 1.4. Then tries all public parameterless getter methods, which return a Throwable. Then tries all member fields of Throwable or a subtype. If any of such trials succeeeds in getting a Throwable object, which is not the same as i_throwable, then returns it. If none succeeds, returns null.

Specified by:
getCause in interface CauseGetter
Returns:
The exception, which caused i_throwable to be created, or null if none is found.