KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sslexplorer > boot > XMLParseException


1 /* XMLParseException.java
2  *
3  *
4  * This file is part of NanoXML 2 Lite.
5  * Copyright (C) 2000-2002 Marc De Scheemaecker, All Rights Reserved.
6  *
7  * This software is provided 'as-is', without any express or implied warranty.
8  * In no event will the authors be held liable for any damages arising from the
9  * use of this software.
10  *
11  * Permission is granted to anyone to use this software for any purpose,
12  * including commercial applications, and to alter it and redistribute it
13  * freely, subject to the following restrictions:
14  *
15  * 1. The origin of this software must not be misrepresented; you must not
16  * claim that you wrote the original software. If you use this software in
17  * a product, an acknowledgment in the product documentation would be
18  * appreciated but is not required.
19  *
20  * 2. Altered source versions must be plainly marked as such, and must not be
21  * misrepresented as being the original software.
22  *
23  * 3. This notice may not be removed or altered from any source distribution.
24  *****************************************************************************/

25
26 package com.sslexplorer.boot;
27
28
29 /**
30  * An XMLParseException is thrown when an error occures while parsing an XML
31  * string.
32  *
33  * @see XMLElement
34  *
35  * @author Marc De Scheemaecker
36  */

37 public class XMLParseException
38     extends RuntimeException JavaDoc
39 {
40
41     /**
42      * Indicates that no line number has been associated with this exception.
43      */

44     public static final int NO_LINE = -1;
45
46
47     /**
48      * The line number in the source code where the error occurred, or
49      * <code>NO_LINE</code> if the line number is unknown.
50      *
51      * <dl><dt><b>Invariants:</b></dt><dd>
52      * <ul><li><code>lineNr &gt 0 || lineNr == NO_LINE</code>
53      * </ul></dd></dl>
54      */

55     private int lineNr;
56
57
58     /**
59      * Creates an exception.
60      *
61      * @param name The name of the element where the error is located.
62      * @param message A message describing what went wrong.
63      *
64      * </dl><dl><dt><b>Preconditions:</b></dt><dd>
65      * <ul><li><code>message != null</code>
66      * </ul></dd></dl>
67      *
68      * <dl><dt><b>Postconditions:</b></dt><dd>
69      * <ul><li>getLineNr() => NO_LINE
70      * </ul></dd></dl><dl>
71      */

72     public XMLParseException(String JavaDoc name,
73                              String JavaDoc message)
74     {
75         super("XML Parse Exception during parsing of "
76               + ((name == null) ? "the XML definition"
77                                 : ("a " + name + " element"))
78               + ": " + message);
79         this.lineNr = XMLParseException.NO_LINE;
80     }
81
82
83     /**
84      * Creates an exception.
85      *
86      * @param name The name of the element where the error is located.
87      * @param lineNr The number of the line in the input.
88      * @param message A message describing what went wrong.
89      *
90      * </dl><dl><dt><b>Preconditions:</b></dt><dd>
91      * <ul><li><code>message != null</code>
92      * <li><code>lineNr &gt; 0</code>
93      * </ul></dd></dl>
94      *
95      * <dl><dt><b>Postconditions:</b></dt><dd>
96      * <ul><li>getLineNr() => lineNr
97      * </ul></dd></dl><dl>
98      */

99     public XMLParseException(String JavaDoc name,
100                              int lineNr,
101                              String JavaDoc message)
102     {
103         super("XML Parse Exception during parsing of "
104               + ((name == null) ? "the XML definition"
105                                 : ("a " + name + " element"))
106               + " at line " + lineNr + ": " + message);
107         this.lineNr = lineNr;
108     }
109
110
111     /**
112      * Where the error occurred, or <code>NO_LINE</code> if the line number is
113      * unknown.
114      *
115      * @return line number
116      * @see XMLParseException#NO_LINE
117      */

118     public int getLineNr()
119     {
120         return this.lineNr;
121     }
122
123 }
124
Popular Tags