1 | package reverter.corehacks;
|
---|
2 |
|
---|
3 | import static org.openstreetmap.josm.tools.I18n.tr;
|
---|
4 |
|
---|
5 | import org.xml.sax.Locator;
|
---|
6 | import org.xml.sax.SAXException;
|
---|
7 |
|
---|
8 | public class OsmDataParsingException extends SAXException {
|
---|
9 | private int columnNumber;
|
---|
10 | private int lineNumber;
|
---|
11 |
|
---|
12 | public OsmDataParsingException() {
|
---|
13 | super();
|
---|
14 | }
|
---|
15 |
|
---|
16 | public OsmDataParsingException(Exception e) {
|
---|
17 | super(e);
|
---|
18 | }
|
---|
19 |
|
---|
20 | public OsmDataParsingException(String message, Exception e) {
|
---|
21 | super(message, e);
|
---|
22 | }
|
---|
23 |
|
---|
24 | public OsmDataParsingException(String message) {
|
---|
25 | super(message);
|
---|
26 | }
|
---|
27 |
|
---|
28 | public OsmDataParsingException rememberLocation(Locator locator) {
|
---|
29 | if (locator == null) return this;
|
---|
30 | this.columnNumber = locator.getColumnNumber();
|
---|
31 | this.lineNumber = locator.getLineNumber();
|
---|
32 | return this;
|
---|
33 | }
|
---|
34 |
|
---|
35 | @Override
|
---|
36 | public String getMessage() {
|
---|
37 | String msg = super.getMessage();
|
---|
38 | if (lineNumber == 0 && columnNumber == 0)
|
---|
39 | return msg;
|
---|
40 | if (msg == null) {
|
---|
41 | msg = getClass().getName();
|
---|
42 | }
|
---|
43 | msg = msg + " " + tr("(at line {0}, column {1})", lineNumber, columnNumber);
|
---|
44 | return msg;
|
---|
45 | }
|
---|
46 |
|
---|
47 | public int getColumnNumber() {
|
---|
48 | return columnNumber;
|
---|
49 | }
|
---|
50 |
|
---|
51 | public int getLineNumber() {
|
---|
52 | return lineNumber;
|
---|
53 | }
|
---|
54 | }
|
---|