Desktop tool for browsing account info from EVE-Online
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

JDOMParseException.java 6.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. /*--
  2. $Id: JDOMParseException.java,v 1.8 2007/11/10 05:29:00 jhunter Exp $
  3. Copyright (C) 2000-2007 Jason Hunter & Brett McLaughlin.
  4. All rights reserved.
  5. Redistribution and use in source and binary forms, with or without
  6. modification, are permitted provided that the following conditions
  7. are met:
  8. 1. Redistributions of source code must retain the above copyright
  9. notice, this list of conditions, and the following disclaimer.
  10. 2. Redistributions in binary form must reproduce the above copyright
  11. notice, this list of conditions, and the disclaimer that follows
  12. these conditions in the documentation and/or other materials
  13. provided with the distribution.
  14. 3. The name "JDOM" must not be used to endorse or promote products
  15. derived from this software without prior written permission. For
  16. written permission, please contact <request_AT_jdom_DOT_org>.
  17. 4. Products derived from this software may not be called "JDOM", nor
  18. may "JDOM" appear in their name, without prior written permission
  19. from the JDOM Project Management <request_AT_jdom_DOT_org>.
  20. In addition, we request (but do not require) that you include in the
  21. end-user documentation provided with the redistribution and/or in the
  22. software itself an acknowledgement equivalent to the following:
  23. "This product includes software developed by the
  24. JDOM Project (http://www.jdom.org/)."
  25. Alternatively, the acknowledgment may be graphical using the logos
  26. available at http://www.jdom.org/images/logos.
  27. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  28. WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  29. OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  30. DISCLAIMED. IN NO EVENT SHALL THE JDOM AUTHORS OR THE PROJECT
  31. CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  32. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  33. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  34. USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  35. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  36. OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  37. OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  38. SUCH DAMAGE.
  39. This software consists of voluntary contributions made by many
  40. individuals on behalf of the JDOM Project and was originally
  41. created by Jason Hunter <jhunter_AT_jdom_DOT_org> and
  42. Brett McLaughlin <brett_AT_jdom_DOT_org>. For more information
  43. on the JDOM Project, please see <http://www.jdom.org/>.
  44. */
  45. package org.jdom.input;
  46. import org.jdom.*;
  47. import org.xml.sax.*;
  48. /**
  49. * Thrown during parse errors, with information about where the parse error
  50. * occurred as well as access to the partially built document.
  51. *
  52. * @version $Revision: 1.8 $, $Date: 2007/11/10 05:29:00 $
  53. * @author Laurent Bihanic
  54. */
  55. public class JDOMParseException extends JDOMException {
  56. private static final String CVS_ID =
  57. "@(#) $RCSfile: JDOMParseException.java,v $ $Revision: 1.8 $ $Date: 2007/11/10 05:29:00 $ $Name: jdom_1_1 $";
  58. /**
  59. * The portion of the document that was successfully built before
  60. * the parse error occurred.
  61. */
  62. private final Document partialDocument;
  63. /**
  64. * This will create a parse <code>Exception</code> with the given
  65. * message and wrap the <code>Exception</code> that cause a document
  66. * parse to fail.
  67. *
  68. * @param message <code>String</code> message indicating
  69. * the problem that occurred.
  70. * @param cause <code>Throwable</code> that caused this
  71. * to be thrown.
  72. */
  73. public JDOMParseException(String message, Throwable cause) {
  74. this(message, cause, null);
  75. }
  76. /**
  77. * This will create a parse <code>Exception</code> with the given
  78. * message and the partial document and wrap the
  79. * <code>Exception</code> that cause a document parse to fail.
  80. *
  81. * @param message <code>String</code> message indicating
  82. * the problem that occurred.
  83. * @param cause <code>Throwable</code> that caused this
  84. * to be thrown.
  85. * @param partialDocument <code>Document</code> the portion of
  86. * the input XML document that was
  87. * successfully built.
  88. */
  89. public JDOMParseException(String message, Throwable cause,
  90. Document partialDocument) {
  91. super(message, cause);
  92. this.partialDocument = partialDocument;
  93. }
  94. /**
  95. * Returns the partial document that was successfully built before
  96. * the error occurred.
  97. *
  98. * @return the partial document or null if none.
  99. */
  100. public Document getPartialDocument() {
  101. return partialDocument;
  102. }
  103. /**
  104. * Returns the public identifier of the entity where the
  105. * parse error occurred.
  106. *
  107. * @return a string containing the public identifier, or
  108. * <code>null</code> if the information is not available.
  109. */
  110. public String getPublicId() {
  111. return (getCause() instanceof SAXParseException)?
  112. ((SAXParseException)getCause()).getPublicId(): null;
  113. }
  114. /**
  115. * Returns the system identifier of the entity where the
  116. * parse error occurred.
  117. *
  118. * @return a string containing the system identifier, or
  119. * <code>null</code> if the information is not available.
  120. */
  121. public String getSystemId() {
  122. return (getCause() instanceof SAXParseException)?
  123. ((SAXParseException)getCause()).getSystemId(): null;
  124. }
  125. /**
  126. * Returns the line number of the end of the text where the
  127. * parse error occurred.
  128. * <p>
  129. * The first line in the document is line 1.</p>
  130. *
  131. * @return an integer representing the line number, or -1
  132. * if the information is not available.
  133. */
  134. public int getLineNumber() {
  135. return (getCause() instanceof SAXParseException)?
  136. ((SAXParseException)getCause()).getLineNumber(): -1;
  137. }
  138. /**
  139. * Returns the column number of the end of the text where the
  140. * parse error occurred.
  141. * <p>
  142. * The first column in a line is position 1.</p>
  143. *
  144. * @return an integer representing the column number, or -1
  145. * if the information is not available.
  146. */
  147. public int getColumnNumber() {
  148. return (getCause() instanceof SAXParseException)?
  149. ((SAXParseException)getCause()).getColumnNumber(): -1;
  150. }
  151. }