001: /* XMLParseException.java
002: *
003: * $Revision: 1.4 $
004: * $Date: 2002/03/24 10:27:59 $
005: * $Name: RELEASE_2_2_1 $
006: *
007: * This file is part of NanoXML 2 Lite.
008: * Copyright (C) 2000-2002 Marc De Scheemaecker, All Rights Reserved.
009: *
010: * This software is provided 'as-is', without any express or implied warranty.
011: * In no event will the authors be held liable for any damages arising from the
012: * use of this software.
013: *
014: * Permission is granted to anyone to use this software for any purpose,
015: * including commercial applications, and to alter it and redistribute it
016: * freely, subject to the following restrictions:
017: *
018: * 1. The origin of this software must not be misrepresented; you must not
019: * claim that you wrote the original software. If you use this software in
020: * a product, an acknowledgment in the product documentation would be
021: * appreciated but is not required.
022: *
023: * 2. Altered source versions must be plainly marked as such, and must not be
024: * misrepresented as being the original software.
025: *
026: * 3. This notice may not be removed or altered from any source distribution.
027: *****************************************************************************/
028:
029: package com.jidesoft.plaf.aqua;
030:
031: /**
032: * An XMLParseException is thrown when an error occures while parsing an XML
033: * string.
034: * <p/>
035: * $Revision: 1.4 $<BR>
036: * $Date: 2002/03/24 10:27:59 $<P>
037: *
038: * @author Marc De Scheemaecker
039: * @version $Name: RELEASE_2_2_1 $, $Revision: 1.4 $
040: * @see XMLElement
041: */
042: class XMLParseException extends RuntimeException {
043:
044: /**
045: * Indicates that no line number has been associated with this exception.
046: */
047: public static final int NO_LINE = -1;
048:
049: /**
050: * The line number in the source code where the error occurred, or
051: * <code>NO_LINE</code> if the line number is unknown.
052: * <p/>
053: * <dl><dt><b>Invariants:</b></dt><dd>
054: * <ul><li><code>lineNr > 0 || lineNr == NO_LINE</code>
055: * </ul></dd></dl>
056: */
057: private int lineNr;
058:
059: /**
060: * Creates an exception.
061: *
062: * @param name The name of the element where the error is located.
063: * @param message A message describing what went wrong.
064: * <p/>
065: * </dl><dl><dt><b>Preconditions:</b></dt><dd>
066: * <ul><li><code>message != null</code>
067: * </ul></dd></dl>
068: * <p/>
069: * <dl><dt><b>Postconditions:</b></dt><dd>
070: * <ul><li>getLineNr() => NO_LINE
071: * </ul></dd></dl><dl>
072: */
073: public XMLParseException(String name, String message) {
074: super ("XML Parse Exception during parsing of "
075: + ((name == null) ? "the XML definition"
076: : ("a " + name + " element")) + ": " + message);
077: this .lineNr = XMLParseException.NO_LINE;
078: }
079:
080: /**
081: * Creates an exception.
082: *
083: * @param name The name of the element where the error is located.
084: * @param lineNr The number of the line in the input.
085: * @param message A message describing what went wrong.
086: * <p/>
087: * </dl><dl><dt><b>Preconditions:</b></dt><dd>
088: * <ul><li><code>message != null</code>
089: * <li><code>lineNr > 0</code>
090: * </ul></dd></dl>
091: * <p/>
092: * <dl><dt><b>Postconditions:</b></dt><dd>
093: * <ul><li>getLineNr() => lineNr
094: * </ul></dd></dl><dl>
095: */
096: public XMLParseException(String name, int lineNr, String message) {
097: super ("XML Parse Exception during parsing of "
098: + ((name == null) ? "the XML definition"
099: : ("a " + name + " element")) + " at line "
100: + lineNr + ": " + message);
101: this .lineNr = lineNr;
102: }
103:
104: /**
105: * Where the error occurred, or <code>NO_LINE</code> if the line number is
106: * unknown.
107: *
108: * @see nanoxml.XMLParseException#NO_LINE
109: */
110: public int getLineNr() {
111: return this.lineNr;
112: }
113:
114: }
|