01: /* Copyright 2004 The JA-SIG Collaborative. All rights reserved.
02: * See license distributed with this file and
03: * available online at http://www.uportal.org/license.html
04: */
05:
06: package org.jasig.portal.channels.error.error2xml;
07:
08: import org.w3c.dom.Document;
09: import org.w3c.dom.Element;
10:
11: /**
12: * Interface for translating from a Throwable to an Element.
13: * @author andrew.petro@yale.edu
14: * @version $Revision: 35593 $ $Date: 2005-04-17 13:54:14 -0700 (Sun, 17 Apr 2005) $
15: * @since uPortal 2.5
16: */
17: public interface IThrowableToElement {
18:
19: // Exceptions as Elements look like this:
20: // <exception code="N">
21: // <resource><uri/><description/></resource>
22: // <timeout value="N"/>
23: // </exception>
24:
25: /**
26: * Obtain an Element representing the throwable.
27: * Throws IllegalArgumentException if t is null.
28: * Throws IllegalArgumentException if t is not supported, as indicated by
29: * the supports() method.
30: * @param t a supported throwable
31: * @param parentDoc document into which the element is to go
32: * @return an Element representing the Element
33: * @throws IllegalArgumentException if t is null.
34: * @throws IllegalArgumentException if t is unsupported.
35: */
36: public Element throwableToElement(Throwable t, Document parentDoc)
37: throws IllegalArgumentException;
38:
39: /**
40: * Returns true if the implementation knows how to translate an instance
41: * of the given class into an Element (throwableToElement() will return non-null)
42: * for instances of the class, which must extend Throwable). Returns false
43: * if the implementation will return null for throwableToNode() on an instance
44: * of the class. Throws IllegalArgumentException if c is not a class which
45: * extends Throwable. Throws IllegalArgumentException if c is null.
46: * @param c a Class extending Throwable
47: * @return true if handles instances of c, false otherwise
48: * @throws IllegalArgumentException if c is null or does not extend Throwable
49: */
50: public boolean supports(Class c) throws IllegalArgumentException;
51:
52: }
|