multex
Class Util

java.lang.Object
  extended bymultex.Util

public class Util
extends java.lang.Object

Utilities for MulTEx. Usually methods of this class should not be called by framework client code. Each exception (chain) should be reported by methods of classes Msg or Awt, or Swing.
But if the format of the mentioned reporting classes is not approriate for your purposes, then you can create your own reporting methods by the help of this MulTEx utility class.

Since:
MulTEx 6 on 2005-01-13
Author:
Christoph Knabe

Nested Class Summary
static class Util.MyDemoExc
          The demonstration of action ''{0}'' failed by fault of person {1}.
 
Field Summary
static char causeIndenter
          The char used to indent one level of causal chain when reporting the messages or stack trace of an exception chain.
static java.lang.String lineSeparator
          Returns the line separator for the actual platform.
static java.lang.String wasCausing
          The string used to delimit the stack trace part of a causing exception from the following stack trace of the caused exception.
 
Constructor Summary
Util()
           
 
Method Summary
static java.lang.Object[] clone(java.lang.Object[] i_array)
          Returns a new copy of the array or null, if null was provided
static java.lang.Throwable getCause(java.lang.Throwable i_throwable)
          Result: The directly causing Throwable of i_throwable, if there is one, otherwise null.
static java.lang.Throwable[] getCauses(java.lang.Throwable i_throwable)
          Result: The directly causing Throwables of i_throwable, if there are some, otherwise null.
static java.lang.Throwable getContainedException(java.lang.Throwable i_throwableChain, java.lang.Class i_expectedThrowableClass)
          Returns the upmost exception in i_throwableChain, which is of class i_expectedThrowableClass, helpwise null.
static java.lang.Throwable getOriginalException(java.lang.Throwable i_throwable)
          Result: The deepest Throwable object, which indirectly caused the program to throw i_throwable, if there is one, otherwise i_throwable itself.
static boolean jreHasExceptionChaining()
          Returns true, if class java.lang.Throwable has an operation getCause() in this Java Runtime Environment
static void setCauseGetter(CauseGetter i_causeGetter)
          Sets a CauseGetter to be used by method getCause(Throwable) in order to get the cause of a Throwable object.
static java.lang.String toString(java.lang.Throwable i_throwable)
          For low level reporting of an exception.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

lineSeparator

public static final java.lang.String lineSeparator
Returns the line separator for the actual platform. This is the line separator for the platform the Java virtual machine is running on. It is the value of the system property 'line.separator'.


wasCausing

public static final java.lang.String wasCausing
The string used to delimit the stack trace part of a causing exception from the following stack trace of the caused exception.

See Also:
Constant Field Values

causeIndenter

public static final char causeIndenter
The char used to indent one level of causal chain when reporting the messages or stack trace of an exception chain.

Since:
MulTEx 6d 2006-05-16
See Also:
Constant Field Values
Constructor Detail

Util

public Util()
Method Detail

clone

public static java.lang.Object[] clone(java.lang.Object[] i_array)
Returns a new copy of the array or null, if null was provided

Since:
MulTEx 6 on 2005-01-13

setCauseGetter

public static final void setCauseGetter(CauseGetter i_causeGetter)
Sets a CauseGetter to be used by method getCause(Throwable) in order to get the cause of a Throwable object. Default is ReflectionCauseGetter


getCauses

public static final java.lang.Throwable[] getCauses(java.lang.Throwable i_throwable)
Result: The directly causing Throwables of i_throwable, if there are some, otherwise null. This method is better than Throwable.getCause(Throwable) in following legacy exception chaining, as it uses the ReflectionCauseGetter by default. You can replace the cause getter by method setCauseGetter(multex.CauseGetter). The cause getter is used only for getting a cause, which is returned by a method of the Throwable. All MulTEx parameters of this Throwable, which are themselves instances of Throwable, are returned, too.


getCause

public static final java.lang.Throwable getCause(java.lang.Throwable i_throwable)
Result: The directly causing Throwable of i_throwable, if there is one, otherwise null. This method is better than Throwable.getCause(Throwable) in following legacy exception chaining, as it uses the ReflectionCauseGetter by default. You can replace the cause getter by method setCauseGetter(multex.CauseGetter).


jreHasExceptionChaining

public static boolean jreHasExceptionChaining()
Returns true, if class java.lang.Throwable has an operation getCause() in this Java Runtime Environment


getContainedException

public static java.lang.Throwable getContainedException(java.lang.Throwable i_throwableChain,
                                                        java.lang.Class i_expectedThrowableClass)
Returns the upmost exception in i_throwableChain, which is of class i_expectedThrowableClass, helpwise null. Usage e.g. for a FieldValueExc, which is thrown from the business logic layer to the user interface layer, wrapped some times on this way, but should trigger a uniform reaction on the user interface layer (Marking the named form field as erroneous, and issuing its error message).


getOriginalException

public static final java.lang.Throwable getOriginalException(java.lang.Throwable i_throwable)
Result: The deepest Throwable object, which indirectly caused the program to throw i_throwable, if there is one, otherwise i_throwable itself.

See Also:
getCause(Throwable)

toString

public static java.lang.String toString(java.lang.Throwable i_throwable)
For low level reporting of an exception. Preferably use this toString(), than the JDK-provided throwable.toString(). The JDK reports in the format package.subpackage.ClassName: throwable.getMessage(), which is suitably redefined for any MultexException, too.

But some legacy-chained exceptions like org.xml.sax.SAXException suppress the class name of this exception and instead of it return the toString() of the causing exception. As to obtain all exception class names in a causal chain, we use our own toString(), which includes firstly a mere copy of Throwable.toString().and then the toString() of the reported exception.