View Javadoc
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.codehaus.plexus.util.xml.pull;
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
12      extends Exception
13  {
14      /**
15       * @deprecated use generic getCause() method
16       */
17      protected Throwable detail;
18  
19      protected int row = -1;
20  
21      protected int column = -1;
22  
23      /*
24       * public XmlPullParserException() { }
25       */
26  
27      public XmlPullParserException( String s )
28      {
29          super( s );
30      }
31  
32      /*
33       * public XmlPullParserException(String s, Throwable throwable) { super(s); this.detail = throwable; } public
34       * XmlPullParserException(String s, int row, int column) { super(s); this.row = row; this.column = column; }
35       */
36  
37      public XmlPullParserException( String msg, XmlPullParser parser, Throwable chain )
38      {
39          super( ( msg == null ? "" : msg + " " )
40              + ( parser == null ? "" : "(position:" + parser.getPositionDescription() + ") " )
41              + ( chain == null ? "" : "caused by: " + chain ), chain );
42  
43          if ( parser != null )
44          {
45              this.row = parser.getLineNumber();
46              this.column = parser.getColumnNumber();
47          }
48          this.detail = chain;
49      }
50  
51      /**
52       * @deprecated Use the generic <code>getCause()</code> method
53       * @return
54       */
55      public Throwable getDetail()
56      {
57          return getCause();
58      }
59  
60      // public void setDetail(Throwable cause) { this.detail = cause; }
61      public int getLineNumber()
62      {
63          return row;
64      }
65  
66      public int getColumnNumber()
67      {
68          return column;
69      }
70  
71      /*
72       * public String getMessage() { if(detail == null) return super.getMessage(); else return super.getMessage() +
73       * "; nested exception is: \n\t" + detail.getMessage(); }
74       */
75  
76      // NOTE: code that prints this and detail is difficult in J2ME
77      public void printStackTrace()
78      {
79          if ( getCause() == null )
80          {
81              super.printStackTrace();
82          }
83          else
84          {
85              synchronized ( System.err )
86              {
87                  System.err.println( super.getMessage() + "; nested exception is:" );
88                  getCause().printStackTrace();
89              }
90          }
91      }
92  
93  }