01: package com.sun.portal.rewriter.engines.xml.parser;
02:
03: import java.io.PrintStream;
04: import java.io.PrintWriter;
05:
06: public final class XMLParseException extends Exception {
07: private String msg;
08: private Exception encapsulatedException;
09:
10: public XMLParseException(final String systemID, final int lineNr,
11: final String msg) {
12: this (systemID, lineNr, null, msg, true);
13: }
14:
15: public XMLParseException(final String systemID, final int lineNr,
16: final Exception e, final String msg,
17: final boolean reportParams) {
18: super (buildMessage(systemID, lineNr, e, msg, reportParams));
19: this .encapsulatedException = e;
20: this .msg = buildMessage(systemID, lineNr, e, msg, reportParams);
21: }
22:
23: public void printStackTrace(PrintWriter writer) {
24: super .printStackTrace(writer);
25:
26: if (this .encapsulatedException != null) {
27: writer.println("*** Nested Exception:");
28: this .encapsulatedException.printStackTrace(writer);
29: }
30: }
31:
32: public void printStackTrace(PrintStream stream) {
33: super .printStackTrace(stream);
34:
35: if (this .encapsulatedException != null) {
36: stream.println("*** Nested Exception:");
37: this .encapsulatedException.printStackTrace(stream);
38: }
39: }
40:
41: public void printStackTrace() {
42: super .printStackTrace();
43:
44: if (this .encapsulatedException != null) {
45: System.err.println("*** Nested Exception:");
46: this .encapsulatedException.printStackTrace();
47: }
48: }
49:
50: public String toString() {
51: return msg;
52: }//toString()
53:
54: private static String buildMessage(String systemID, int lineNr,
55: Exception e, String msg, boolean reportParams) {
56: String str = msg;
57:
58: if (reportParams) {
59: if (systemID != null) {
60: str += ", SystemID='" + systemID + "'";
61: }
62:
63: if (lineNr >= 0) {
64: str += ", Line=" + lineNr;
65: }
66:
67: if (e != null) {
68: str += ", Exception: " + e;
69: }
70: }
71:
72: return str;
73: }//buildMessage()
74:
75: }//class XMLParseException
|