jut.lang
Class NestedException

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by java.lang.RuntimeException
              extended by jut.lang.NestedException
All Implemented Interfaces:
Serializable

public class NestedException
extends RuntimeException

wrapper class for wrapping a Throwable in a RuntimeException. the main use for this is to wrap declared exceptions in interface implementations that do not declare exceptions themselves, like Runnable. as far as possible, a NestedException exposes the properties of the wrapped Throwable.

this class solves the problem that some interfaces in the standard JDK do not declare exceptions but the implementing classes should throw a declared exception.

Author:
Georg Dietrich
See Also:
Serialized Form

Constructor Summary
NestedException(Throwable throwable)
          wrap a Throwable into a RuntimeException.
 
Method Summary
 Throwable getCause()
           
 String getLocalizedMessage()
           
 String getMessage()
           
 StackTraceElement[] getStackTrace()
           
 Throwable getThrowable()
          returns the nested Throwable that is wrapped by this NestedException.
 void printStackTrace()
          prints the stack trace of the nested Throwable.
 void printStackTrace(PrintStream printStream)
          prints the stack trace of the nested Throwable.
 void printStackTrace(PrintWriter printWriter)
          prints the stack trace of the nested Throwable.
 String toString()
          returns a short description of the nested Throwable.
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, initCause, setStackTrace
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NestedException

public NestedException(Throwable throwable)
wrap a Throwable into a RuntimeException.

Parameters:
throwable - - the Throwable to wrap.
Method Detail

getThrowable

public Throwable getThrowable()
returns the nested Throwable that is wrapped by this NestedException.

Returns:
the nested Throwable that is wrapped by this NestedException.

getCause

public Throwable getCause()
Overrides:
getCause in class Throwable
Returns:
the cause of the nested Throwable.
See Also:
Throwable.getCause()

getLocalizedMessage

public String getLocalizedMessage()
Overrides:
getLocalizedMessage in class Throwable
Returns:
the localized message of the nested Throwable.
See Also:
Throwable.getLocalizedMessage()

getMessage

public String getMessage()
Overrides:
getMessage in class Throwable
Returns:
the message of the nested Throwable.
See Also:
Throwable.getMessage()

getStackTrace

public StackTraceElement[] getStackTrace()
Overrides:
getStackTrace in class Throwable
Returns:
the stack trace of the nested Throwable.
See Also:
Throwable.getStackTrace()

printStackTrace

public void printStackTrace()
prints the stack trace of the nested Throwable.

Overrides:
printStackTrace in class Throwable
See Also:
Throwable.printStackTrace()

printStackTrace

public void printStackTrace(PrintStream printStream)
prints the stack trace of the nested Throwable.

Overrides:
printStackTrace in class Throwable
Parameters:
printStream - - the PrintStream to use for output
See Also:
Throwable.printStackTrace(PrintStream)

printStackTrace

public void printStackTrace(PrintWriter printWriter)
prints the stack trace of the nested Throwable.

Overrides:
printStackTrace in class Throwable
Parameters:
printWriter - - the PrintWriter to use for output
See Also:
Throwable.printStackTrace(PrintWriter)

toString

public String toString()
returns a short description of the nested Throwable.

Overrides:
toString in class Throwable
Returns:
a short description of the nested Throwable.
See Also:
Throwable.toString()