1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package net.sf.xolite;
17
18
19
20
21
22
23
24 public class XMLParseException extends Exception {
25
26 private static final long serialVersionUID = -5693785937821376660L;
27
28 private String source;
29 private int line = -1;
30 private int column = -1;
31
32
33 public XMLParseException(String message) {
34 super(message);
35 }
36
37
38 public XMLParseException(String message, Throwable cause) {
39 super(message, cause);
40 }
41
42
43 @Override
44 public String getMessage() {
45 StringBuilder sb = new StringBuilder();
46
47 sb.append(super.getMessage());
48
49 if (source != null) {
50 sb.append("\n\t\tin ");
51 sb.append(source);
52 }
53
54 if (line >= 0) {
55 sb.append("\n\t\tat line ");
56 sb.append(line);
57 if (column >= 0) {
58 sb.append(", column ");
59 sb.append(column);
60 }
61 }
62 return sb.toString();
63 }
64
65
66 public void setSource(String sourceDescription) {
67 source = sourceDescription;
68 }
69
70
71 public void setLocation(int newLine, int newColumn) {
72 line = newLine;
73 column = newColumn;
74 }
75
76
77 public String getSource() {
78 return source;
79 }
80
81
82 public int getLine() {
83 return line;
84 }
85
86
87 public int getColumn() {
88 return column;
89 }
90
91 }