src/share/classes/sun/util/xml/XMLParseException.java
author Jaroslav Tulach <jtulach@netbeans.org>
Wed, 24 Jun 2009 16:38:24 +0200
branchxml-sax-and-dom-2
changeset 1262 52864f10883d
permissions -rw-r--r--
By default (when no XML SAX and DOM 2 present) parsing the properties stream with simple nanoXML parser
jtulach@1262
     1
/* XMLParseException.java
jtulach@1262
     2
 *
jtulach@1262
     3
 * $Revision: 1.4 $
jtulach@1262
     4
 * $Date: 2002/03/24 10:27:59 $
jtulach@1262
     5
 * $Name: RELEASE_2_2_1 $
jtulach@1262
     6
 *
jtulach@1262
     7
 * This file is part of NanoXML 2 Lite.
jtulach@1262
     8
 * Copyright (C) 2000-2002 Marc De Scheemaecker, All Rights Reserved.
jtulach@1262
     9
 *
jtulach@1262
    10
 * This software is provided 'as-is', without any express or implied warranty.
jtulach@1262
    11
 * In no event will the authors be held liable for any damages arising from the
jtulach@1262
    12
 * use of this software.
jtulach@1262
    13
 *
jtulach@1262
    14
 * Permission is granted to anyone to use this software for any purpose,
jtulach@1262
    15
 * including commercial applications, and to alter it and redistribute it
jtulach@1262
    16
 * freely, subject to the following restrictions:
jtulach@1262
    17
 *
jtulach@1262
    18
 *  1. The origin of this software must not be misrepresented; you must not
jtulach@1262
    19
 *     claim that you wrote the original software. If you use this software in
jtulach@1262
    20
 *     a product, an acknowledgment in the product documentation would be
jtulach@1262
    21
 *     appreciated but is not required.
jtulach@1262
    22
 *
jtulach@1262
    23
 *  2. Altered source versions must be plainly marked as such, and must not be
jtulach@1262
    24
 *     misrepresented as being the original software.
jtulach@1262
    25
 *
jtulach@1262
    26
 *  3. This notice may not be removed or altered from any source distribution.
jtulach@1262
    27
 *****************************************************************************/
jtulach@1262
    28
jtulach@1262
    29
jtulach@1262
    30
 package sun.util.xml;
jtulach@1262
    31
jtulach@1262
    32
jtulach@1262
    33
/**
jtulach@1262
    34
 * An XMLParseException is thrown when an error occures while parsing an XML
jtulach@1262
    35
 * string.
jtulach@1262
    36
 * <P>
jtulach@1262
    37
 * $Revision: 1.4 $<BR>
jtulach@1262
    38
 * $Date: 2002/03/24 10:27:59 $<P>
jtulach@1262
    39
 *
jtulach@1262
    40
 * @see nanoxml.XMLElement
jtulach@1262
    41
 *
jtulach@1262
    42
 * @author Marc De Scheemaecker
jtulach@1262
    43
 * @version $Name: RELEASE_2_2_1 $, $Revision: 1.4 $
jtulach@1262
    44
 */
jtulach@1262
    45
class XMLParseException extends RuntimeException
jtulach@1262
    46
{
jtulach@1262
    47
jtulach@1262
    48
    /**
jtulach@1262
    49
     * Indicates that no line number has been associated with this exception.
jtulach@1262
    50
     */
jtulach@1262
    51
    public static final int NO_LINE = -1;
jtulach@1262
    52
jtulach@1262
    53
jtulach@1262
    54
    /**
jtulach@1262
    55
     * The line number in the source code where the error occurred, or
jtulach@1262
    56
     * <code>NO_LINE</code> if the line number is unknown.
jtulach@1262
    57
     *
jtulach@1262
    58
     * <dl><dt><b>Invariants:</b></dt><dd>
jtulach@1262
    59
     * <ul><li><code>lineNr &gt 0 || lineNr == NO_LINE</code>
jtulach@1262
    60
     * </ul></dd></dl>
jtulach@1262
    61
     */
jtulach@1262
    62
    private int lineNr;
jtulach@1262
    63
jtulach@1262
    64
jtulach@1262
    65
    /**
jtulach@1262
    66
     * Creates an exception.
jtulach@1262
    67
     *
jtulach@1262
    68
     * @param name    The name of the element where the error is located.
jtulach@1262
    69
     * @param message A message describing what went wrong.
jtulach@1262
    70
     *
jtulach@1262
    71
     * </dl><dl><dt><b>Preconditions:</b></dt><dd>
jtulach@1262
    72
     * <ul><li><code>message != null</code>
jtulach@1262
    73
     * </ul></dd></dl>
jtulach@1262
    74
     *
jtulach@1262
    75
     * <dl><dt><b>Postconditions:</b></dt><dd>
jtulach@1262
    76
     * <ul><li>getLineNr() => NO_LINE
jtulach@1262
    77
     * </ul></dd></dl><dl>
jtulach@1262
    78
     */
jtulach@1262
    79
    public XMLParseException(String name,
jtulach@1262
    80
                             String message)
jtulach@1262
    81
    {
jtulach@1262
    82
        super("XML Parse Exception during parsing of "
jtulach@1262
    83
              + ((name == null) ? "the XML definition"
jtulach@1262
    84
                                : ("a " + name + " element"))
jtulach@1262
    85
              + ": " + message);
jtulach@1262
    86
        this.lineNr = XMLParseException.NO_LINE;
jtulach@1262
    87
    }
jtulach@1262
    88
jtulach@1262
    89
jtulach@1262
    90
    /**
jtulach@1262
    91
     * Creates an exception.
jtulach@1262
    92
     *
jtulach@1262
    93
     * @param name    The name of the element where the error is located.
jtulach@1262
    94
     * @param lineNr  The number of the line in the input.
jtulach@1262
    95
     * @param message A message describing what went wrong.
jtulach@1262
    96
     *
jtulach@1262
    97
     * </dl><dl><dt><b>Preconditions:</b></dt><dd>
jtulach@1262
    98
     * <ul><li><code>message != null</code>
jtulach@1262
    99
     *     <li><code>lineNr &gt; 0</code>
jtulach@1262
   100
     * </ul></dd></dl>
jtulach@1262
   101
     *
jtulach@1262
   102
     * <dl><dt><b>Postconditions:</b></dt><dd>
jtulach@1262
   103
     * <ul><li>getLineNr() => lineNr
jtulach@1262
   104
     * </ul></dd></dl><dl>
jtulach@1262
   105
     */
jtulach@1262
   106
    public XMLParseException(String name,
jtulach@1262
   107
                             int    lineNr,
jtulach@1262
   108
                             String message)
jtulach@1262
   109
    {
jtulach@1262
   110
        super("XML Parse Exception during parsing of "
jtulach@1262
   111
              + ((name == null) ? "the XML definition"
jtulach@1262
   112
                                : ("a " + name + " element"))
jtulach@1262
   113
              + " at line " + lineNr + ": " + message);
jtulach@1262
   114
        this.lineNr = lineNr;
jtulach@1262
   115
    }
jtulach@1262
   116
jtulach@1262
   117
jtulach@1262
   118
    /**
jtulach@1262
   119
     * Where the error occurred, or <code>NO_LINE</code> if the line number is
jtulach@1262
   120
     * unknown.
jtulach@1262
   121
     *
jtulach@1262
   122
     * @see nanoxml.XMLParseException#NO_LINE
jtulach@1262
   123
     */
jtulach@1262
   124
    public int getLineNr()
jtulach@1262
   125
    {
jtulach@1262
   126
        return this.lineNr;
jtulach@1262
   127
    }
jtulach@1262
   128
jtulach@1262
   129
}