1 /*
2  * Copyright (c) 2001-2004 World Wide Web Consortium,
3  * (Massachusetts Institute of Technology, Institut National de
4  * Recherche en Informatique et en Automatique, Keio University). All
5  * Rights Reserved. This program is distributed under the W3C's Software
6  * Intellectual Property License. This program is distributed in the
7  * hope that it will be useful, but WITHOUT ANY WARRANTY; without even
8  * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
9  * PURPOSE.
10  * See W3C License http://www.w3.org/Consortium/Legal/ for more details.
11  */
12 
13 
14 package org.w3c.domts;
15 
16 
17 /**
18  * This exception represents a mismatch between the
19  * requirements of the test (for example, entity preserving)
20  * and the capabilities of the parser under test.
21  * @author Curt Arnold
22  */
23 public class DOMTestIncompatibleException
24     extends Exception {
25   private final String msg;
26 
DOMTestIncompatibleException(String msg)27   private DOMTestIncompatibleException(String msg) {
28     this.msg = msg;
29   }
30 
31   /**
32    *  Constructor from a ParserConfigurationException
33    *  or reflection exception
34    */
DOMTestIncompatibleException(Throwable ex, DocumentBuilderSetting setting)35   public DOMTestIncompatibleException(Throwable ex,
36                                       DocumentBuilderSetting setting) {
37     if (ex != null) {
38       msg = ex.toString();
39     }
40     else {
41       if (setting != null) {
42         msg = setting.toString();
43       }
44       else {
45         msg = super.toString();
46       }
47     }
48   }
49 
incompatibleFeature(String feature, String version)50   public static DOMTestIncompatibleException incompatibleFeature(String feature,
51       String version) {
52     StringBuffer buf = new StringBuffer(
53         "Implementation does not support feature \"");
54     buf.append(feature);
55     buf.append("\" version=\"");
56     buf.append(version);
57     buf.append("\".");
58     return new DOMTestIncompatibleException(buf.toString());
59   }
60 
incompatibleLoad(String href, String contentType)61   public static DOMTestIncompatibleException incompatibleLoad(String href,
62       String contentType) {
63     StringBuffer buf = new StringBuffer(
64         "Document is incompatible with content type, \"");
65     buf.append(href);
66     buf.append("\" not available for =\"");
67     buf.append(contentType);
68     buf.append("\".");
69     return new DOMTestIncompatibleException(buf.toString());
70   }
71 
toString()72   public String toString() {
73     return msg;
74   }
75 
76 }
77