1 28 29 package net.n3.nanoxml; 30 31 import java.io.PrintStream ; 32 import java.io.PrintWriter ; 33 34 40 public class XMLException extends Exception 41 { 42 43 46 private static final long serialVersionUID = 3256727298916299056L; 47 48 51 private String systemID; 52 53 56 private int lineNr; 57 58 61 private Exception encapsulatedException; 62 63 68 public XMLException(String msg) 69 { 70 this(null, -1, null, msg, false); 71 } 72 73 78 public XMLException(Exception e) 79 { 80 this(null, -1, e, e.getMessage(), false); 81 } 82 83 90 public XMLException(String systemID, int lineNr, Exception e) 91 { 92 this(systemID, lineNr, e, "Nested Exception", true); 93 } 94 95 102 public XMLException(String systemID, int lineNr, String msg) 103 { 104 this(systemID, lineNr, null, msg, true); 105 } 106 107 117 public XMLException(String systemID, int lineNr, Exception e, String msg, boolean reportParams) 118 { 119 super(msg 120 + (reportParams ? (((systemID == null) ? "" : (", SystemID='" + systemID + "'")) 121 + ((lineNr == -1) ? "" : (", Line=" + lineNr)) + ((e == null) ? "" 122 : (", Exception: " + e))) : "")); 123 this.systemID = systemID; 124 this.lineNr = lineNr; 125 this.encapsulatedException = e; 126 } 127 128 131 protected void finalize() throws Throwable 132 { 133 this.systemID = null; 134 this.encapsulatedException = null; 135 super.finalize(); 136 } 137 138 142 public String getSystemID() 143 { 144 return this.systemID; 145 } 146 147 151 public int getLineNr() 152 { 153 return this.lineNr; 154 } 155 156 159 public Exception getException() 160 { 161 return this.encapsulatedException; 162 } 163 164 169 public void printStackTrace(PrintWriter writer) 170 { 171 if (this.encapsulatedException != null) 172 { 173 this.encapsulatedException.printStackTrace(writer); 174 } 175 176 super.printStackTrace(writer); 177 } 178 179 184 public void printStackTrace(PrintStream stream) 185 { 186 if (this.encapsulatedException != null) 187 { 188 this.encapsulatedException.printStackTrace(stream); 189 } 190 191 super.printStackTrace(stream); 192 } 193 194 197 public void printStackTrace() 198 { 199 if (this.encapsulatedException != null) 200 { 201 this.encapsulatedException.printStackTrace(); 202 } 203 204 super.printStackTrace(); 205 } 206 207 } 208 | Popular Tags |