KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > xml > xpath > XPathException


1 // $Id: XPathException.java,v 1.14.12.2 2004/06/15 00:07:08 rameshm Exp $
2

3 /*
4  * @(#)XPathException.java 1.8 04/07/26
5  *
6  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
7  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
8  */

9
10 package javax.xml.xpath;
11
12 import java.io.PrintWriter JavaDoc;
13
14 /**
15  * <code>XPathException</code> represents a generic XPath exception.</p>
16  *
17  * @author <a HREF="Norman.Walsh@Sun.com">Norman Walsh</a>
18  * @author <a HREF="mailto:Jeff.Suttor@Sun.COM">Jeff Suttor</a>
19  * @version $Revision: 1.14.12.2 $, $Date: 2004/06/15 00:07:08 $
20  * @since 1.5
21  */

22 public class XPathException extends Exception JavaDoc {
23
24     private final Throwable JavaDoc cause;
25     
26     /**
27      * <p>Stream Unique Identifier.</p>
28      */

29     private static final long serialVersionUID = -1837080260374986980L;
30
31     /**
32      * <p>Constructs a new <code>XPathException</code> with the specified detail <code>message</code>.</p>
33      *
34      * <p>The <code>cause</code> is not initialized.</p>
35      *
36      * <p>If <code>message</code> is <code>null</code>, then a <code>NullPointerException</code> is thrown.</p>
37      *
38      * @param message The detail message.
39      */

40     public XPathException(String JavaDoc message) {
41         super(message);
42         if ( message == null ) {
43             throw new NullPointerException JavaDoc ( "message can't be null");
44         }
45         this.cause = null;
46     }
47
48     /**
49      * <p>Constructs a new <code>XPathException</code> with the specified <code>cause</code>.</p>
50      *
51      * <p>If <code>cause</code> is <code>null</code>, then a <code>NullPointerException</code> is thrown.</p>
52      *
53      * @param cause The cause.
54      *
55      * @throws NullPointerException if <code>cause</code> is <code>null</code>.
56      */

57     public XPathException(Throwable JavaDoc cause) {
58         super();
59         this.cause = cause;
60         if ( cause == null ) {
61             throw new NullPointerException JavaDoc ( "cause can't be null");
62         }
63     }
64     
65     public Throwable JavaDoc getCause() {
66         return cause;
67     }
68
69     public void printStackTrace( java.io.PrintStream JavaDoc s ) {
70         if( getCause() != null ) {
71             getCause().printStackTrace(s);
72           s.println("--------------- linked to ------------------");
73         }
74
75         super.printStackTrace(s);
76     }
77  
78     public void printStackTrace() {
79         printStackTrace(System.err);
80     }
81
82     public void printStackTrace(PrintWriter JavaDoc s) {
83         if( getCause() != null ) {
84             getCause().printStackTrace(s);
85           s.println("--------------- linked to ------------------");
86         }
87
88         super.printStackTrace(s);
89     }
90 }
91
Popular Tags