View Javadoc

1   /*
2    * Copyright 2001-2005 (C) MetaStuff, Ltd. All Rights Reserved.
3    *
4    * This software is open source.
5    * See the bottom of this file for the licence.
6    */
7   
8   package org.dom4j;
9   
10  /***
11   * <p>
12   * <code>XPathException</code> is thrown when an exception occurs while
13   * evaluating an XPath expression, usually due to some function throwing an
14   * exception.
15   * </p>
16   * 
17   * @version $Revision: 1.6 $
18   */
19  public class XPathException extends RuntimeException {
20      /*** The XPath expression that caused the exception */
21      private String xpath;
22  
23      public XPathException(String xpath) {
24          super("Exception occurred evaluting XPath: " + xpath);
25          this.xpath = xpath;
26      }
27  
28      public XPathException(String xpath, String reason) {
29          super("Exception occurred evaluting XPath: " + xpath + " " + reason);
30          this.xpath = xpath;
31      }
32  
33      public XPathException(String xpath, Exception e) {
34          super("Exception occurred evaluting XPath: " + xpath + ". Exception: "
35                  + e.getMessage());
36          this.xpath = xpath;
37      }
38  
39      /***
40       * Returns the XPath expression that caused the problem
41       * 
42       * @return DOCUMENT ME!
43       */
44      public String getXPath() {
45          return xpath;
46      }
47  }
48  
49  /*
50   * Redistribution and use of this software and associated documentation
51   * ("Software"), with or without modification, are permitted provided that the
52   * following conditions are met:
53   * 
54   * 1. Redistributions of source code must retain copyright statements and
55   * notices. Redistributions must also contain a copy of this document.
56   * 
57   * 2. Redistributions in binary form must reproduce the above copyright notice,
58   * this list of conditions and the following disclaimer in the documentation
59   * and/or other materials provided with the distribution.
60   * 
61   * 3. The name "DOM4J" must not be used to endorse or promote products derived
62   * from this Software without prior written permission of MetaStuff, Ltd. For
63   * written permission, please contact dom4j-info@metastuff.com.
64   * 
65   * 4. Products derived from this Software may not be called "DOM4J" nor may
66   * "DOM4J" appear in their names without prior written permission of MetaStuff,
67   * Ltd. DOM4J is a registered trademark of MetaStuff, Ltd.
68   * 
69   * 5. Due credit should be given to the DOM4J Project - http://www.dom4j.org
70   * 
71   * THIS SOFTWARE IS PROVIDED BY METASTUFF, LTD. AND CONTRIBUTORS ``AS IS'' AND
72   * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
73   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
74   * ARE DISCLAIMED. IN NO EVENT SHALL METASTUFF, LTD. OR ITS CONTRIBUTORS BE
75   * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
76   * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
77   * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
78   * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
79   * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
80   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
81   * POSSIBILITY OF SUCH DAMAGE.
82   * 
83   * Copyright 2001-2005 (C) MetaStuff, Ltd. All Rights Reserved.
84   */