2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / libjava / org / xml / sax / SAXParseException.java
blobe87d79f3f741732b49c0fc5cda972040e8683188
1 // SAX exception class.
2 // http://www.saxproject.org
3 // No warranty; no copyright -- use this as you will.
4 // $Id: SAXParseException.java,v 1.3.2.5 2002/01/29 21:34:14 dbrownell Exp $
6 package org.xml.sax;
8 /**
9 * Encapsulate an XML parse error or warning.
11 * <blockquote>
12 * <em>This module, both source code and documentation, is in the
13 * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
14 * See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
15 * for further information.
16 * </blockquote>
18 * <p>This exception may include information for locating the error
19 * in the original XML document, as if it came from a {@link Locator}
20 * object. Note that although the application
21 * will receive a SAXParseException as the argument to the handlers
22 * in the {@link org.xml.sax.ErrorHandler ErrorHandler} interface,
23 * the application is not actually required to throw the exception;
24 * instead, it can simply read the information in it and take a
25 * different action.</p>
27 * <p>Since this exception is a subclass of {@link org.xml.sax.SAXException
28 * SAXException}, it inherits the ability to wrap another exception.</p>
30 * @since SAX 1.0
31 * @author David Megginson
32 * @version 2.0.1 (sax2r2)
33 * @see org.xml.sax.SAXException
34 * @see org.xml.sax.Locator
35 * @see org.xml.sax.ErrorHandler
37 public class SAXParseException extends SAXException {
40 //////////////////////////////////////////////////////////////////////
41 // Constructors.
42 //////////////////////////////////////////////////////////////////////
45 /**
46 * Create a new SAXParseException from a message and a Locator.
48 * <p>This constructor is especially useful when an application is
49 * creating its own exception from within a {@link org.xml.sax.ContentHandler
50 * ContentHandler} callback.</p>
52 * @param message The error or warning message.
53 * @param locator The locator object for the error or warning (may be
54 * null).
55 * @see org.xml.sax.Locator
57 public SAXParseException (String message, Locator locator) {
58 super(message);
59 if (locator != null) {
60 init(locator.getPublicId(), locator.getSystemId(),
61 locator.getLineNumber(), locator.getColumnNumber());
62 } else {
63 init(null, null, -1, -1);
68 /**
69 * Wrap an existing exception in a SAXParseException.
71 * <p>This constructor is especially useful when an application is
72 * creating its own exception from within a {@link org.xml.sax.ContentHandler
73 * ContentHandler} callback, and needs to wrap an existing exception that is not a
74 * subclass of {@link org.xml.sax.SAXException SAXException}.</p>
76 * @param message The error or warning message, or null to
77 * use the message from the embedded exception.
78 * @param locator The locator object for the error or warning (may be
79 * null).
80 * @param e Any exception.
81 * @see org.xml.sax.Locator
83 public SAXParseException (String message, Locator locator,
84 Exception e) {
85 super(message, e);
86 if (locator != null) {
87 init(locator.getPublicId(), locator.getSystemId(),
88 locator.getLineNumber(), locator.getColumnNumber());
89 } else {
90 init(null, null, -1, -1);
95 /**
96 * Create a new SAXParseException.
98 * <p>This constructor is most useful for parser writers.</p>
100 * <p>All parameters except the message are as if
101 * they were provided by a {@link Locator}. For example, if the
102 * system identifier is a URL (including relative filename), the
103 * caller must resolve it fully before creating the exception.</p>
106 * @param message The error or warning message.
107 * @param publicId The public identifer of the entity that generated
108 * the error or warning.
109 * @param systemId The system identifer of the entity that generated
110 * the error or warning.
111 * @param lineNumber The line number of the end of the text that
112 * caused the error or warning.
113 * @param columnNumber The column number of the end of the text that
114 * cause the error or warning.
116 public SAXParseException (String message, String publicId, String systemId,
117 int lineNumber, int columnNumber)
119 super(message);
120 init(publicId, systemId, lineNumber, columnNumber);
125 * Create a new SAXParseException with an embedded exception.
127 * <p>This constructor is most useful for parser writers who
128 * need to wrap an exception that is not a subclass of
129 * {@link org.xml.sax.SAXException SAXException}.</p>
131 * <p>All parameters except the message and exception are as if
132 * they were provided by a {@link Locator}. For example, if the
133 * system identifier is a URL (including relative filename), the
134 * caller must resolve it fully before creating the exception.</p>
136 * @param message The error or warning message, or null to use
137 * the message from the embedded exception.
138 * @param publicId The public identifer of the entity that generated
139 * the error or warning.
140 * @param systemId The system identifer of the entity that generated
141 * the error or warning.
142 * @param lineNumber The line number of the end of the text that
143 * caused the error or warning.
144 * @param columnNumber The column number of the end of the text that
145 * cause the error or warning.
146 * @param e Another exception to embed in this one.
148 public SAXParseException (String message, String publicId, String systemId,
149 int lineNumber, int columnNumber, Exception e)
151 super(message, e);
152 init(publicId, systemId, lineNumber, columnNumber);
157 * Internal initialization method.
159 * @param publicId The public identifier of the entity which generated the exception,
160 * or null.
161 * @param systemId The system identifier of the entity which generated the exception,
162 * or null.
163 * @param lineNumber The line number of the error, or -1.
164 * @param columnNumber The column number of the error, or -1.
166 private void init (String publicId, String systemId,
167 int lineNumber, int columnNumber)
169 this.publicId = publicId;
170 this.systemId = systemId;
171 this.lineNumber = lineNumber;
172 this.columnNumber = columnNumber;
177 * Get the public identifier of the entity where the exception occurred.
179 * @return A string containing the public identifier, or null
180 * if none is available.
181 * @see org.xml.sax.Locator#getPublicId
183 public String getPublicId ()
185 return this.publicId;
190 * Get the system identifier of the entity where the exception occurred.
192 * <p>If the system identifier is a URL, it will have been resolved
193 * fully.</p>
195 * @return A string containing the system identifier, or null
196 * if none is available.
197 * @see org.xml.sax.Locator#getSystemId
199 public String getSystemId ()
201 return this.systemId;
206 * The line number of the end of the text where the exception occurred.
208 * <p>The first line is line 1.</p>
210 * @return An integer representing the line number, or -1
211 * if none is available.
212 * @see org.xml.sax.Locator#getLineNumber
214 public int getLineNumber ()
216 return this.lineNumber;
221 * The column number of the end of the text where the exception occurred.
223 * <p>The first column in a line is position 1.</p>
225 * @return An integer representing the column number, or -1
226 * if none is available.
227 * @see org.xml.sax.Locator#getColumnNumber
229 public int getColumnNumber ()
231 return this.columnNumber;
236 //////////////////////////////////////////////////////////////////////
237 // Internal state.
238 //////////////////////////////////////////////////////////////////////
242 * @serial The public identifier, or null.
243 * @see #getPublicId
245 private String publicId;
249 * @serial The system identifier, or null.
250 * @see #getSystemId
252 private String systemId;
256 * @serial The line number, or -1.
257 * @see #getLineNumber
259 private int lineNumber;
263 * @serial The column number, or -1.
264 * @see #getColumnNumber
266 private int columnNumber;
270 // end of SAXParseException.java