XmlPullParserException.java 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /* -*- c-basic-offset: 4; indent-tabs-mode: nil; -*- //------100-columns-wide------>|*/
  2. // for license please see accompanying XmlPull license file (available also at http://www.xmlpull.org/)
  3. package org.xmlpull.v1;
  4. /**
  5. * This exception is thrown to signal XML Pull Parser related faults.
  6. *
  7. * @author <a href="http://www.extreme.indiana.edu/~aslom/">Aleksander Slominski</a>
  8. */
  9. public class XmlPullParserException extends Exception {
  10. protected Throwable detail;
  11. protected int row = -1;
  12. protected int column = -1;
  13. /* public XmlPullParserException() {
  14. }*/
  15. public XmlPullParserException(String s) {
  16. super(s);
  17. }
  18. /*
  19. public XmlPullParserException(String s, Throwable thrwble) {
  20. super(s);
  21. this.detail = thrwble;
  22. }
  23. public XmlPullParserException(String s, int row, int column) {
  24. super(s);
  25. this.row = row;
  26. this.column = column;
  27. }
  28. */
  29. public XmlPullParserException(String msg, IXmlPullParser parser, Throwable chain) {
  30. super ((msg == null ? "" : msg+" ")
  31. + (parser == null ? "" : "(position:"+parser.getPositionDescription()+") ")
  32. + (chain == null ? "" : "caused by: "+chain));
  33. if (parser != null) {
  34. this.row = parser.getLineNumber();
  35. this.column = parser.getColumnNumber();
  36. }
  37. this.detail = chain;
  38. }
  39. public Throwable getDetail() { return detail; }
  40. // public void setDetail(Throwable cause) { this.detail = cause; }
  41. public int getLineNumber() { return row; }
  42. public int getColumnNumber() { return column; }
  43. /*
  44. public String getMessage() {
  45. if(detail == null)
  46. return super.getMessage();
  47. else
  48. return super.getMessage() + "; nested exception is: \n\t"
  49. + detail.getMessage();
  50. }
  51. */
  52. //NOTE: code that prints this and detail is difficult in J2ME
  53. public void printStackTrace() {
  54. if (detail == null) {
  55. super.printStackTrace();
  56. } else {
  57. synchronized(System.err) {
  58. System.err.println(super.getMessage() + "; nested exception is:");
  59. detail.printStackTrace();
  60. }
  61. }
  62. }
  63. }