View Javadoc
1   /* 
2    * The NanoXML 2 Lite licence blurb is included here. The classes have been 
3    * completely butchered but the core xml parsing routines are thanks to 
4    * the NanoXML authors.
5    *  
6    **/
7   
8   /* XMLParseException.java
9    *
10   * $Revision: 1.4 $
11   * $Date: 2002/03/24 10:27:59 $
12   * $Name: RELEASE_2_2_1 $
13   *
14   * This file is part of NanoXML 2 Lite.
15   * Copyright (C) 2000-2002 Marc De Scheemaecker, All Rights Reserved.
16   *
17   * This software is provided 'as-is', without any express or implied warranty.
18   * In no event will the authors be held liable for any damages arising from the
19   * use of this software.
20   *
21   * Permission is granted to anyone to use this software for any purpose,
22   * including commercial applications, and to alter it and redistribute it
23   * freely, subject to the following restrictions:
24   *
25   *  1. The origin of this software must not be misrepresented; you must not
26   *     claim that you wrote the original software. If you use this software in
27   *     a product, an acknowledgment in the product documentation would be
28   *     appreciated but is not required.
29   *
30   *  2. Altered source versions must be plainly marked as such, and must not be
31   *     misrepresented as being the original software.
32   *
33   *  3. This notice may not be removed or altered from any source distribution.
34   *****************************************************************************/
35  
36  
37  package com.github.davidmoten.aws.lw.client.xml;
38  
39  /**
40   * An XMLParseException is thrown when an error occures while parsing an XML
41   * string.
42   * <P>
43   * $Revision: 1.4 $<BR>
44   * $Date: 2002/03/24 10:27:59 $<P>
45   *
46   * @see com.github.davidmoten.aws.lw.client.xml.XmlElement
47   *
48   * @author Marc De Scheemaecker
49   * @version $Name: RELEASE_2_2_1 $, $Revision: 1.4 $
50   */
51  public class XmlParseException
52      extends RuntimeException
53  {
54  
55      /**
56       * 
57       */
58      private static final long serialVersionUID = 2719032602966457493L;
59  
60  
61      /**
62       * Indicates that no line number has been associated with this exception.
63       */
64      public static final int NO_LINE = -1;
65  
66  
67      /**
68       * The line number in the source code where the error occurred, or
69       * <code>NO_LINE</code> if the line number is unknown.
70       *
71       * <dl><dt><b>Invariants:</b></dt><dd>
72       * <ul><li><code>lineNumber &gt 0 || lineNumber == NO_LINE</code>
73       * </ul></dd></dl>
74       */
75      private int lineNumber;
76  
77      /**
78       * Creates an exception.
79       *
80       * @param name    The name of the element where the error is located.
81       * @param lineNumber  The number of the line in the input.
82       * @param message A message describing what went wrong.
83       *
84       * </dl><dl><dt><b>Preconditions:</b></dt><dd>
85       * <ul><li><code>message != null</code>
86       *     <li><code>lineNumber &gt; 0</code>
87       * </ul></dd></dl>
88       *
89       * <dl><dt><b>Postconditions:</b></dt><dd>
90       * <ul><li>getLineNumber() => lineNr
91       * </ul></dd></dl><dl>
92       */
93      public XmlParseException(String name,
94                               int    lineNumber,
95                               String message)
96      {
97          super("Problem parsing "
98                + ((name == null) ? "the XML definition"
99                                  : ("a " + name + " element"))
100               + " at line " + lineNumber + ": " + message);
101         this.lineNumber = lineNumber;
102     }
103 
104 
105     /**
106      * Where the error occurred, or <code>NO_LINE</code> if the line number is
107      * unknown.
108      *
109      */
110     public int lineNumber()
111     {
112         return this.lineNumber;
113     }
114 
115 }