Source code: nanoxml/kXMLParseException.java
1 /* This file is part of NanoXML.
2 *
3 * NanoXML 1.6.8 for J2ME -- This file has been altered from the
4 * original, whose copyright message is shown below. The alterations
5 * are small and only enough to make it compatible with CLDC-based
6 * J2ME profiles.
7 *
8 * Modifications are by Eric Giguere, ericgiguere@ericgiguere.com.
9 *
10 * $Revision: 1.1 $
11 * $Date: 2002/05/13 17:34:51 $
12 * $Name: build_20030502 $
13 *
14 * Copyright (C) 2000 Marc De Scheemaecker, All Rights Reserved.
15 *
16 * This software is provided 'as-is', without any express or implied warranty.
17 * In no event will the authors be held liable for any damages arising from the
18 * use of this software.
19 *
20 * Permission is granted to anyone to use this software for any purpose,
21 * including commercial applications, and to alter it and redistribute it
22 * freely, subject to the following restrictions:
23 *
24 * 1. The origin of this software must not be misrepresented; you must not
25 * claim that you wrote the original software. If you use this software in
26 * a product, an acknowledgment in the product documentation would be
27 * appreciated but is not required.
28 *
29 * 2. Altered source versions must be plainly marked as such, and must not be
30 * misrepresented as being the original software.
31 *
32 * 3. This notice may not be removed or altered from any source distribution.
33 */
34
35
36 package nanoxml;
37
38
39 /**
40 * An kXMLParseException is thrown when an error occures while parsing an XML
41 * string.
42 * <P>
43 * $Revision: 1.1 $<BR>
44 * $Date: 2002/05/13 17:34:51 $<P>
45 *
46 * @see nanoxml.kXMLElement
47 *
48 * @author Marc De Scheemaecker
49 * <<A HREF="mailto:Marc.DeScheemaecker@advalvas.be"
50 * >Marc.DeScheemaecker@advalvas.be</A>>
51 * @version 1.6
52 */
53 public class kXMLParseException
54 extends RuntimeException
55 {
56
57 /**
58 * Where the error occurred, or -1 if the line number is unknown.
59 */
60 private int lineNr;
61
62
63 /**
64 * Creates an exception.
65 *
66 * @param tag The name of the tag where the error is located.
67 * @param message A message describing what went wrong.
68 */
69 public kXMLParseException(String tag,
70 String message)
71 {
72 super("XML Parse Exception during parsing of "
73 + ((tag == null) ? "the XML definition" : ("a " + tag + "-tag"))
74 + ": " + message);
75 this.lineNr = -1;
76 }
77
78
79 /**
80 * Creates an exception.
81 *
82 * @param tag The name of the tag where the error is located.
83 * @param lineNr The number of the line in the input.
84 * @param message A message describing what went wrong.
85 */
86 public kXMLParseException(String tag,
87 int lineNr,
88 String message)
89 {
90 super("XML Parse Exception during parsing of "
91 + ((tag == null) ? "the XML definition" : ("a " + tag + "-tag"))
92 + " at line " + lineNr + ": " + message);
93 this.lineNr = lineNr;
94 }
95
96
97 /**
98 * Where the error occurred, or -1 if the line number is unknown.
99 */
100 public int getLineNr()
101 {
102 return this.lineNr;
103 }
104
105 }