org.yajul.util
Class ExceptionList

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by org.yajul.util.ExceptionList
All Implemented Interfaces:
java.io.Serializable

public class ExceptionList
extends java.lang.Exception

A checked exception that contains a list of other exceptions.
User: josh Date: Oct 24, 2003 Time: 7:51:20 AM

See Also:
Serialized Form

Constructor Summary
ExceptionList()
          Constructs a new exception with null as its detail message.
ExceptionList(java.lang.String message)
          Constructs a new exception with the specified detail message.
ExceptionList(java.lang.String message, java.lang.Throwable cause)
          Constructs a new exception with the specified detail message and cause.
ExceptionList(java.lang.Throwable cause)
          Constructs a new exception with the specified cause and a detail message of (cause==null ? null : cause.toString()) (which typically contains the class and detail message of cause).
 
Method Summary
 void add(java.lang.Throwable t)
          Adds a new exception (Throwable) to the list.
 java.lang.Throwable getCause()
          Returns the cause of this throwable or null if the cause is nonexistent or unknown.
 java.lang.String getLocalizedMessage()
          Creates a localized description of this throwable.
 java.lang.String getMessage()
          Returns the detail message string of this throwable.
 java.util.Iterator iterator()
          Returns an iterator which will provide all of the Throwables.
 void printStackTrace()
          Prints a stack trace.
 void printStackTrace(java.io.PrintStream s)
          Prints a stack trace to the specified print stream.
 void printStackTrace(java.io.PrintWriter w)
          Prints this throwable and its backtrace to the specified print writer.
 int size()
          Returns the number of throwables in the list.
 void throwIfException()
          Throws this ExceptionList object if there are more than one throwables in the list.
 void throwIfThrowable()
          Throws this ExceptionList object if there are more than one throwables in the list.
 java.lang.String toString()
          Converts everything to a string.
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getStackTrace, initCause, setStackTrace
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ExceptionList

public ExceptionList()
Constructs a new exception with null as its detail message. The cause is not initialized, and may subsequently be initialized by a call to initCause.


ExceptionList

public ExceptionList(java.lang.String message)
Constructs a new exception with the specified detail message. The cause is not initialized, and may subsequently be initialized by a call to initCause.

Parameters:
message - the detail message. The detail message is saved for later retrieval by the getMessage() method.

ExceptionList

public ExceptionList(java.lang.String message,
                     java.lang.Throwable cause)
Constructs a new exception with the specified detail message and cause.

Note that the detail message associated with cause is not automatically incorporated in this exception's detail message.

Parameters:
message - the detail message (which is saved for later retrieval by the getMessage() method).
cause - the cause (which is saved for later retrieval by the getCause() method). (A null value is permitted, and indicates that the cause is nonexistent or unknown.)

ExceptionList

public ExceptionList(java.lang.Throwable cause)
Constructs a new exception with the specified cause and a detail message of (cause==null ? null : cause.toString()) (which typically contains the class and detail message of cause). This constructor is useful for exceptions that are little more than wrappers for other throwables (for example, java.security.PrivilegedActionException).

Parameters:
cause - the cause (which is saved for later retrieval by the getCause() method). (A null value is permitted, and indicates that the cause is nonexistent or unknown.)
Method Detail

getCause

public java.lang.Throwable getCause()
Returns the cause of this throwable or null if the cause is nonexistent or unknown. (The cause is the throwable that caused this throwable to get thrown.)

This implementation returns the cause that was supplied via one of the constructors requiring a Throwable, or that was set after creation with the initCause(Throwable) method. While it is typically unnecessary to override this method, a subclass can override it to return a cause set by some other means. This is appropriate for a "legacy chained throwable" that predates the addition of chained exceptions to Throwable. Note that it is not necessary to override any of the PrintStackTrace methods, all of which invoke the getCause method to determine the cause of a throwable.

Overrides:
getCause in class java.lang.Throwable
Returns:
the cause of this throwable or null if the cause is nonexistent or unknown.

toString

public java.lang.String toString()
Converts everything to a string.

Overrides:
toString in class java.lang.Throwable
Returns:
a string.

getMessage

public java.lang.String getMessage()
Returns the detail message string of this throwable.

Overrides:
getMessage in class java.lang.Throwable
Returns:
the detail message string of this Throwable instance (which may be null).

getLocalizedMessage

public java.lang.String getLocalizedMessage()
Creates a localized description of this throwable. Subclasses may override this method in order to produce a locale-specific message. For subclasses that do not override this method, the default implementation returns the same result as getMessage().

Overrides:
getLocalizedMessage in class java.lang.Throwable
Returns:
The localized description of this throwable.
Since:
JDK1.1

printStackTrace

public void printStackTrace()
Prints a stack trace.

Overrides:
printStackTrace in class java.lang.Throwable

printStackTrace

public void printStackTrace(java.io.PrintStream s)
Prints a stack trace to the specified print stream.

Overrides:
printStackTrace in class java.lang.Throwable
Parameters:
s - the print stream.

printStackTrace

public void printStackTrace(java.io.PrintWriter w)
Prints this throwable and its backtrace to the specified print writer.

Overrides:
printStackTrace in class java.lang.Throwable
Parameters:
w - the print writer.s

add

public void add(java.lang.Throwable t)
Adds a new exception (Throwable) to the list.

Parameters:
t - The new exception (Throwable).

size

public int size()
Returns the number of throwables in the list.

Returns:
int - The number of throwables in the list.

iterator

public java.util.Iterator iterator()
Returns an iterator which will provide all of the Throwables.

Returns:
Iterator - An iterator of all the Throwables.

throwIfThrowable

public void throwIfThrowable()
                      throws java.lang.Throwable
Throws this ExceptionList object if there are more than one throwables in the list. If there is only one throwable in the list, the throwable element will be thrown.

Throws:
java.lang.Throwable - if the size of the list is not zero.

throwIfException

public void throwIfException()
                      throws java.lang.Exception
Throws this ExceptionList object if there are more than one throwables in the list. If there is only one throwable in the list, *and* that throwable is acutally a checked exception, then the throwable element will be thrown.

Throws:
java.lang.Exception - if the size of the list is not zero.


Copyright © 2008. All Rights Reserved.