org.apache.commons.lang.exception
Class NestableRuntimeException

java.lang.Object
  |
  +--java.lang.Throwable
        |
        +--java.lang.Exception
              |
              +--java.lang.RuntimeException
                    |
                    +--org.apache.commons.lang.exception.NestableRuntimeException
All Implemented Interfaces:
Nestable, java.io.Serializable
Direct Known Subclasses:
SerializationException

public class NestableRuntimeException
extends java.lang.RuntimeException
implements Nestable

The base class of all runtime exceptions which can contain other exceptions.

Version:
$Id: NestableRuntimeException.java,v 1.1 2002/07/19 03:35:54 bayard Exp $
Author:
Rafal Krzewski, Daniel Rall, Kasper Nielsen, Steven Caswell
See Also:
NestableException, Serialized Form

Field Summary
private  java.lang.Throwable cause
          Holds the reference to the exception or error that caused this exception to be thrown.
protected  NestableDelegate delegate
          The helper instance which contains much of the code which we delegate to.
 
Fields inherited from class java.lang.Throwable
backtrace, detailMessage, serialVersionUID
 
Constructor Summary
NestableRuntimeException()
          Constructs a new NestableRuntimeException without specified detail message.
NestableRuntimeException(java.lang.String msg)
          Constructs a new NestableRuntimeException with specified detail message.
NestableRuntimeException(java.lang.String msg, java.lang.Throwable cause)
          Constructs a new NestableRuntimeException with specified detail message and nested Throwable.
NestableRuntimeException(java.lang.Throwable cause)
          Constructs a new NestableRuntimeException with specified nested Throwable.
 
Method Summary
 java.lang.Throwable getCause()
          Returns the reference to the exception or error that caused the exception implementing the Nestable to be thrown.
 int getLength()
          Returns the number of nested Throwables represented by this Nestable, including this Nestable.
 java.lang.String getMessage()
          Returns the error message of this and any nested Throwable.
 java.lang.String getMessage(int index)
          Returns the error message of the Throwable in the chain of Throwables at the specified index, numbererd from 0.
 java.lang.String[] getMessages()
          Returns the error message of this and any nested Throwables in an array of Strings, one element for each message.
 java.lang.Throwable getThrowable(int index)
          Returns the Throwable in the chain of Throwables at the specified index, numbererd from 0.
 java.lang.Throwable[] getThrowables()
          Returns the error message of this and any nested Throwables in an array of Strings, one element for each message.
 int indexOfThrowable(java.lang.Class type)
          Returns the index, numbered from 0, of the first occurrence of the specified type in the chain of Throwables, or -1 if the specified type is not found in the chain.
 int indexOfThrowable(int pos, java.lang.Class type)
          Returns the index, numbered from 0, of the first Throwable that matches the specified type in the chain of Throwables with an index greater than or equal to the specified position, or -1 if the type is not found.
 void printPartialStackTrace(java.io.PrintWriter out)
          Prints the stack trace for this exception only--root cause not included--using the provided writer.
 void printStackTrace()
          Prints the stack trace of this exception the the standar error stream.
 void printStackTrace(java.io.PrintStream out)
          Prints the stack trace of this exception to the specified print stream.
 void printStackTrace(java.io.PrintWriter out)
          Prints the stack trace of this exception to the specified print writer.
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getLocalizedMessage, printStackTrace0, toString
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

delegate

protected NestableDelegate delegate
The helper instance which contains much of the code which we delegate to.

cause

private java.lang.Throwable cause
Holds the reference to the exception or error that caused this exception to be thrown.
Constructor Detail

NestableRuntimeException

public NestableRuntimeException()
Constructs a new NestableRuntimeException without specified detail message.

NestableRuntimeException

public NestableRuntimeException(java.lang.String msg)
Constructs a new NestableRuntimeException with specified detail message.
Parameters:
msg - The error message.

NestableRuntimeException

public NestableRuntimeException(java.lang.Throwable cause)
Constructs a new NestableRuntimeException with specified nested Throwable.
Parameters:
nested - The exception or error that caused this exception to be thrown.

NestableRuntimeException

public NestableRuntimeException(java.lang.String msg,
                                java.lang.Throwable cause)
Constructs a new NestableRuntimeException with specified detail message and nested Throwable.
Parameters:
msg - The error message.
nested - The exception or error that caused this exception to be thrown.
Method Detail

getCause

public java.lang.Throwable getCause()
Description copied from interface: Nestable
Returns the reference to the exception or error that caused the exception implementing the Nestable to be thrown.
Specified by:
getCause in interface Nestable
See Also:
Nestable.getCause()

getLength

public int getLength()
Returns the number of nested Throwables represented by this Nestable, including this Nestable.
Specified by:
getLength in interface Nestable

getMessage

public java.lang.String getMessage()
Description copied from interface: Nestable
Returns the error message of this and any nested Throwable.
Specified by:
getMessage in interface Nestable
Overrides:
getMessage in class java.lang.Throwable
See Also:
Nestable.getMessage()

getMessages

public java.lang.String[] getMessages()
Returns the error message of this and any nested Throwables in an array of Strings, one element for each message. Any Throwable specified without a message is represented in the array by a null.
Specified by:
getMessages in interface Nestable
Following copied from interface: org.apache.commons.lang.exception.Nestable
Returns:
the error messages

getThrowable

public java.lang.Throwable getThrowable(int index)
Description copied from interface: Nestable
Returns the Throwable in the chain of Throwables at the specified index, numbererd from 0. If index is negative, the effect is the same as if it were 0. If index is greater than or equal to the length of the chain, the last Throwable in the chain is returned.
Specified by:
getThrowable in interface Nestable
Following copied from interface: org.apache.commons.lang.exception.Nestable
Parameters:
index - the index of the Throwable in the chain of Throwables
Returns:
the Throwable

getThrowables

public java.lang.Throwable[] getThrowables()
Description copied from interface: Nestable
Returns the error message of this and any nested Throwables in an array of Strings, one element for each message. Any Throwable specified without a message is represented in the array by a null.
Specified by:
getThrowables in interface Nestable
Following copied from interface: org.apache.commons.lang.exception.Nestable
Returns:
the Throwables

getMessage

public java.lang.String getMessage(int index)
Description copied from interface: Nestable
Returns the error message of the Throwable in the chain of Throwables at the specified index, numbererd from 0. If index is negative, the effect is the same as if it were 0. If index is greater than or equal to the length of the chain, the message of the last Throwable in the chain is returned.
Specified by:
getMessage in interface Nestable
Following copied from interface: org.apache.commons.lang.exception.Nestable
Parameters:
index - the index of the Throwable in the chain of Throwables
Returns:
the error message

indexOfThrowable

public int indexOfThrowable(java.lang.Class type)
Returns the index, numbered from 0, of the first occurrence of the specified type in the chain of Throwables, or -1 if the specified type is not found in the chain. If pos is negative, the effect is the same as if it were 0. If pos is greater than or equal to the length of the chain, the effect is the same as if it were the index of the last element in the chain.
Specified by:
indexOfThrowable in interface Nestable
Parameters:
type - Class to be found
Returns:
index of the first occurrence of the type in the chain, or -1 if the type is not found

indexOfThrowable

public int indexOfThrowable(int pos,
                            java.lang.Class type)
Returns the index, numbered from 0, of the first Throwable that matches the specified type in the chain of Throwables with an index greater than or equal to the specified position, or -1 if the type is not found. If pos is negative, the effect is the same as if it were 0. If pos is greater than or equal to the length of the chain, the effect is the same as if it were the index of the last element in the chain.
Specified by:
indexOfThrowable in interface Nestable
Parameters:
type - Class to be found
pos - index, numbered from 0, of the starting position in the chain to be searched
Returns:
index of the first occurrence of the type in the chain, or -1 if the type is not found

printStackTrace

public void printStackTrace()
Prints the stack trace of this exception the the standar error stream.
Overrides:
printStackTrace in class java.lang.Throwable

printStackTrace

public void printStackTrace(java.io.PrintStream out)
Prints the stack trace of this exception to the specified print stream.
Overrides:
printStackTrace in class java.lang.Throwable
Parameters:
out - PrintStream to use for output.

printStackTrace

public void printStackTrace(java.io.PrintWriter out)
Description copied from interface: Nestable
Prints the stack trace of this exception to the specified print writer. Includes inforamation from the exception--if any--which caused this exception.
Specified by:
printStackTrace in interface Nestable
Overrides:
printStackTrace in class java.lang.Throwable
See Also:
Nestable.printStackTrace(PrintWriter out)

printPartialStackTrace

public final void printPartialStackTrace(java.io.PrintWriter out)
Description copied from interface: Nestable
Prints the stack trace for this exception only--root cause not included--using the provided writer. Used by NestableDelegate to write individual stack traces to a buffer. The implementation of this method should call super.printStackTrace(out); in most cases.
Specified by:
printPartialStackTrace in interface Nestable
See Also:
Nestable.printPartialStackTrace(PrintWriter out)


Copyright (c) 2001-2002 - Apache Software Foundation