1 42 43 package org.jfree.xml; 44 45 import java.io.PrintStream ; 46 import java.io.PrintWriter ; 47 48 import org.xml.sax.Locator ; 49 import org.xml.sax.SAXException ; 50 51 56 public class ParseException extends SAXException { 57 58 59 private int line; 60 61 62 private int column; 63 64 69 public ParseException(final String message) { 70 super(message); 71 fillLocation(null); 72 } 73 74 79 public ParseException(final Exception e) { 80 super(e); 81 fillLocation(null); 82 } 83 84 90 public ParseException(final String s, final Exception e) { 91 super(s, e); 92 fillLocation(null); 93 } 94 95 101 public ParseException(final String message, final Locator locator) { 102 super(message); 103 fillLocation(locator); 104 } 105 106 113 public ParseException(final Exception e, final Locator locator) { 114 super(e); 115 fillLocation(locator); 116 } 117 118 126 public ParseException(final String s, final Exception e, final Locator locator) { 127 super(s, e); 128 fillLocation(locator); 129 } 130 131 136 public String getMessage() { 137 final StringBuffer message = new StringBuffer (String.valueOf(super.getMessage())); 138 message.append(" [Location: Line="); 139 message.append(this.line); 140 message.append(" Column="); 141 message.append(this.column); 142 message.append("] "); 143 return message.toString(); 144 } 145 146 151 protected void fillLocation (final Locator locator) { 152 if (locator == null) { 153 this.line = -1; 154 this.column = -1; 155 } 156 else { 157 this.line = locator.getLineNumber(); 158 this.column = locator.getColumnNumber(); 159 } 160 } 161 162 167 public int getLine() { 168 return this.line; 169 } 170 171 176 public int getColumn() { 177 return this.column; 178 } 179 180 181 186 public void printStackTrace(final PrintStream stream) { 187 super.printStackTrace(stream); 188 if (getException() != null) { 189 stream.println("ParentException: "); 190 getException().printStackTrace(stream); 191 } 192 } 193 194 199 public String toString() { 200 return getClass().getName() + ": " + getMessage(); 201 } 202 203 208 public void printStackTrace(final PrintWriter writer) { 209 super.printStackTrace(writer); 210 if (getException() != null) { 211 writer.println("ParentException: "); 212 getException().printStackTrace(writer); 213 } 214 } 215 216 } 217 218
| Popular Tags
|