KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > xmlpull > v1 > XmlPullParserException


1 /* -*- c-basic-offset: 4; indent-tabs-mode: nil; -*- //------100-columns-wide------>|*/
2 // for license please see accompanying LICENSE.txt file (available also at http://www.xmlpull.org/)
3

4 package org.xmlpull.v1;
5
6 /**
7  * This exception is thrown to signal XML Pull Parser related faults.
8  *
9  * @author <a HREF="http://www.extreme.indiana.edu/~aslom/">Aleksander Slominski</a>
10  */

11 public class XmlPullParserException extends Exception JavaDoc {
12     protected Throwable JavaDoc detail;
13     protected int row = -1;
14     protected int column = -1;
15
16     /* public XmlPullParserException() {
17           }*/

18
19     public XmlPullParserException(String JavaDoc s) {
20         super(s);
21     }
22
23     /*
24     public XmlPullParserException(String s, Throwable thrwble) {
25         super(s);
26         this.detail = thrwble;
27         }
28
29     public XmlPullParserException(String s, int row, int column) {
30         super(s);
31         this.row = row;
32         this.column = column;
33     }
34     */

35
36     public XmlPullParserException(String JavaDoc msg, XmlPullParser parser, Throwable JavaDoc chain) {
37         super ((msg == null ? "" : msg+" ")
38                + (parser == null ? "" : "(position:"+parser.getPositionDescription()+") ")
39                + (chain == null ? "" : "caused by: "+chain));
40
41         if (parser != null) {
42             this.row = parser.getLineNumber();
43             this.column = parser.getColumnNumber();
44         }
45         this.detail = chain;
46     }
47
48     public Throwable JavaDoc getDetail() { return detail; }
49     // public void setDetail(Throwable cause) { this.detail = cause; }
50
public int getLineNumber() { return row; }
51     public int getColumnNumber() { return column; }
52
53     /*
54     public String getMessage() {
55         if(detail == null)
56             return super.getMessage();
57         else
58             return super.getMessage() + "; nested exception is: \n\t"
59                 + detail.getMessage();
60     }
61     */

62
63     //NOTE: code that prints this and detail is difficult in J2ME
64
public void printStackTrace() {
65         if (detail == null) {
66             super.printStackTrace();
67         } else {
68             synchronized(System.err) {
69                 System.err.println(super.getMessage() + "; nested exception is:");
70                 detail.printStackTrace();
71             }
72         }
73     }
74
75 }
76
77
Popular Tags