org.apache.commons.lang.exception
Interface Nestable

All Known Implementing Classes:
NestableException, NestableRuntimeException

public interface Nestable

An interface to be implemented by Throwable extensions which would like to be able to nest root exceptions inside themselves.

Version:
$Id: Nestable.java,v 1.1 2002/07/19 03:35:54 bayard Exp $
Author:
Daniel Rall, Kasper Nielsen, Steven Caswell

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(java.io.PrintWriter out)
          Prints the stack trace of this exception to the specified print writer.
 

Method Detail

getCause

public java.lang.Throwable getCause()
Returns the reference to the exception or error that caused the exception implementing the Nestable to be thrown.

getLength

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

getMessage

public java.lang.String getMessage()
Returns the error message of this and any nested Throwable.
Returns:
The error message.

getMessage

public 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. 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.
Parameters:
index - the index of the Throwable in the chain of Throwables
Returns:
the error message

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.
Returns:
the error messages

getThrowable

public java.lang.Throwable getThrowable(int index)
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.
Parameters:
index - the index of the Throwable in the chain of Throwables
Returns:
the Throwable

getThrowables

public java.lang.Throwable[] getThrowables()
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.
Returns:
the Throwables

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.
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.
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(java.io.PrintWriter out)
Prints the stack trace of this exception to the specified print writer. Includes inforamation from the exception--if any--which caused this exception.
Parameters:
out - PrintWriter to use for output.

printPartialStackTrace

public void printPartialStackTrace(java.io.PrintWriter out)
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.
Parameters:
out - The writer to use.


Copyright (c) 2001-2002 - Apache Software Foundation