KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javolution > xml > pull > XmlPullParserException


1 package javolution.xml.pull;
2
3 /**
4  * This exception is thrown to signal XML Pull Parser related faults.
5  *
6  * @author <a HREF="http://www.extreme.indiana.edu/~aslom/">
7  * Aleksander Slominski</a>
8  */

9 public class XmlPullParserException extends Exception {
10
11     protected Throwable detail;
12
13     protected int row = -1;
14
15     protected int column = -1;
16
17     public XmlPullParserException(String s) {
18         super(s);
19     }
20
21     public XmlPullParserException(String msg, XmlPullParser parser,
22             Throwable chain) {
23         super((msg == null ? "" : msg + " ")
24                 + (parser == null ? "" : "(position:"
25                         + parser.getPositionDescription() + ") ")
26                 + (chain == null ? "" : "caused by: " + chain));
27
28         if (parser != null) {
29             this.row = parser.getLineNumber();
30             this.column = parser.getColumnNumber();
31         }
32         this.detail = chain;
33     }
34
35     public Throwable getDetail() {
36         return detail;
37     }
38
39     // public void setDetail(Throwable cause) { this.detail = cause; }
40
public int getLineNumber() {
41         return row;
42     }
43
44     public int getColumnNumber() {
45         return column;
46     }
47
48     //NOTE: code that prints this and detail is difficult in J2ME
49
public void printStackTrace() {
50         if (detail == null) {
51             super.printStackTrace();
52         } else {
53             synchronized (System.err) {
54                 System.err.println(super.getMessage()
55                         + "; nested exception is:");
56                 detail.printStackTrace();
57             }
58         }
59     }
60
61     private static final long serialVersionUID = 3979269131675709496L;
62 }
63
Popular Tags