KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sslexplorer > agent > client > util > XMLParseException


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

24
25 package com.sslexplorer.agent.client.util;
26
27 import java.text.MessageFormat JavaDoc;
28
29
30 /**
31  * An XMLParseException is thrown when an error occures while parsing an XML
32  * string.
33  * <P>
34  *
35  * @see XMLElement
36  *
37  * @author Marc De Scheemaecker
38  */

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

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

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

74     public XMLParseException(String JavaDoc name,
75                              String JavaDoc message)
76     {
77         super(MessageFormat.format(Messages.getString("XMLParseException.xmlParseException"), new Object JavaDoc[] { //$NON-NLS-1$
78
name == null ? "DEF" : name, message } )); //$NON-NLS-1$
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(MessageFormat.format(Messages.getString("XMLParseException.xmlParseExceptionLineNumber"), new Object JavaDoc[] { //$NON-NLS-1$
104
name == null ? "DEF" : name, new Integer JavaDoc(lineNr), message } )); //$NON-NLS-1$
105
this.lineNr = lineNr;
106     }
107
108
109     /**
110      * Where the error occurred, or <code>NO_LINE</code> if the line number is
111      * unknown.
112      *
113      * @return line number
114      * @see XMLParseException#NO_LINE
115      */

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