org.jasig.portal.channels.error.error2xml
Class DelegatingThrowableToElement

java.lang.Object
  extended by org.jasig.portal.channels.error.error2xml.DelegatingThrowableToElement
All Implemented Interfaces:
IThrowableToElement

public class DelegatingThrowableToElement
extends java.lang.Object
implements IThrowableToElement

A wrapper for a List of child ThrowableToElements and the logic to poll them in order, accepting the result from the first to support the given throwable. Defaults to the standard List of ThrowableToElement implementations, but provides API hooks to change the list. You can add handling for other Throwables by either editing this implementation code to include additional ThrowableToElement implementations by default or by injecting a different List of ThrowableToElement implementations where the instance of this class that CError actually uses is configured in applicationContext.xml.

Since:
uPortal 2.5
Version:
$Revision: 1.4 $ $Date: 2005/04/18 20:55:13 $

Field Summary
private  java.util.List throwableToElements
          List of ThrowableToElement implementations in order from most specific to least specific.
 
Constructor Summary
DelegatingThrowableToElement()
          Instantiate a DelegatingThrowableToElement with a default List of delegates.
 
Method Summary
 java.util.List getThrowableToElements()
          Get the List of ThrowableToElements delegates.
 void setThrowableToElements(java.util.List throwableToElements)
          Set the List of ThrowableToElement implementations which this implementation will poll in order.
 boolean supports(java.lang.Class c)
          Returns true if the implementation knows how to translate an instance of the given class into an Element (throwableToElement() will return non-null) for instances of the class, which must extend Throwable).
 org.w3c.dom.Element throwableToElement(java.lang.Throwable t, org.w3c.dom.Document parentDoc)
          Obtain an Element representing the throwable.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

throwableToElements

private java.util.List throwableToElements
List of ThrowableToElement implementations in order from most specific to least specific. These will be polled in order to make our response to our interface methods. Our constructor currently defaults this to a basic list of such mappings.

Constructor Detail

DelegatingThrowableToElement

public DelegatingThrowableToElement()
Instantiate a DelegatingThrowableToElement with a default List of delegates.

Method Detail

getThrowableToElements

public java.util.List getThrowableToElements()
Get the List of ThrowableToElements delegates.

Returns:
Returns the List of throwableToElements delegates..

setThrowableToElements

public void setThrowableToElements(java.util.List throwableToElements)
Set the List of ThrowableToElement implementations which this implementation will poll in order. The List should be in order from most specific to least specific.

Parameters:
throwableToElements - List of ThrowableToElement impls.

supports

public boolean supports(java.lang.Class c)
                 throws java.lang.IllegalArgumentException
Description copied from interface: IThrowableToElement
Returns true if the implementation knows how to translate an instance of the given class into an Element (throwableToElement() will return non-null) for instances of the class, which must extend Throwable). Returns false if the implementation will return null for throwableToNode() on an instance of the class. Throws IllegalArgumentException if c is not a class which extends Throwable. Throws IllegalArgumentException if c is null.

Specified by:
supports in interface IThrowableToElement
Parameters:
c - a Class extending Throwable
Returns:
true if handles instances of c, false otherwise
Throws:
java.lang.IllegalArgumentException - if c is null or does not extend Throwable

throwableToElement

public org.w3c.dom.Element throwableToElement(java.lang.Throwable t,
                                              org.w3c.dom.Document parentDoc)
                                       throws java.lang.IllegalArgumentException
Description copied from interface: IThrowableToElement
Obtain an Element representing the throwable. Throws IllegalArgumentException if t is null. Throws IllegalArgumentException if t is not supported, as indicated by the supports() method.

Specified by:
throwableToElement in interface IThrowableToElement
Parameters:
t - a supported throwable
parentDoc - document into which the element is to go
Returns:
an Element representing the Element
Throws:
java.lang.IllegalArgumentException - if t is null.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object