KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > oracle > toplink > essentials > exceptions > XMLParseException


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the "License"). You may not use this file except
5  * in compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * glassfish/bootstrap/legal/CDDLv1.0.txt or
9  * https://glassfish.dev.java.net/public/CDDLv1.0.html.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * HEADER in each file and include the License file at
15  * glassfish/bootstrap/legal/CDDLv1.0.txt. If applicable,
16  * add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your
18  * own identifying information: Portions Copyright [yyyy]
19  * [name of copyright owner]
20  */

21 // Copyright (c) 1998, 2006, Oracle. All rights reserved.
22
package oracle.toplink.essentials.exceptions;
23
24 import java.io.File JavaDoc;
25 import java.net.URL JavaDoc;
26
27 import oracle.toplink.essentials.exceptions.i18n.*;
28
29 public class XMLParseException extends TopLinkException {
30
31     public static final int EXCEPTION_CREATING_DOCUMENT_BUILDER = 34000;
32     public static final int EXCEPTION_READING_XML_DOCUMENT = 34001;
33     public static final int EXCEPTION_CREATING_SAX_PARSER = 34002;
34     public static final int EXCEPTION_CREATING_XML_READER = 34003;
35     public static final int EXCEPTION_SETTING_SCHEMA_SOURCE = 34004;
36
37     /**
38      * INTERNAL:
39      * TopLink exceptions should only be thrown by TopLink.
40      */

41     public XMLParseException() {
42         super();
43     }
44
45     /**
46      * INTERNAL:
47      * TopLink exceptions should only be thrown by TopLink.
48      */

49     protected XMLParseException(String JavaDoc message) {
50         super(message);
51     }
52
53     /**
54      * INTERNAL:
55      * TopLink exceptions should only be thrown by TopLink.
56      */

57     protected XMLParseException(String JavaDoc message, Throwable JavaDoc internalException) {
58         super(message);
59         setInternalException(internalException);
60     }
61
62     /**
63      * INTERNAL:
64      */

65     public static XMLParseException exceptionCreatingDocumentBuilder(String JavaDoc xmlDocument, Exception JavaDoc cause) {
66         return XMLParseException.getXMLParseException(new Object JavaDoc[] {xmlDocument}, cause, EXCEPTION_CREATING_DOCUMENT_BUILDER);
67     }
68
69     /**
70      * INTERNAL:
71      */

72     public static XMLParseException exceptionCreatingSAXParser(URL JavaDoc url, Exception JavaDoc cause) {
73         return XMLParseException.getXMLParseException(new Object JavaDoc[] {url}, cause, EXCEPTION_CREATING_SAX_PARSER);
74     }
75
76     /**
77      * INTERNAL:
78      */

79     public static XMLParseException exceptionCreatingXMLReader(URL JavaDoc url, Exception JavaDoc cause) {
80         return XMLParseException.getXMLParseException(new Object JavaDoc[] {url}, cause, EXCEPTION_CREATING_XML_READER);
81     }
82
83     /**
84      * INTERNAL:
85      */

86     public static XMLParseException exceptionReadingXMLDocument(String JavaDoc xmlDocument, Exception JavaDoc cause) {
87         return XMLParseException.getXMLParseException(new Object JavaDoc[] {xmlDocument}, cause, EXCEPTION_READING_XML_DOCUMENT);
88     }
89
90     /**
91      * INTERNAL:
92      */

93     public static XMLParseException exceptionSettingSchemaSource(URL JavaDoc baseUrl, URL JavaDoc schemaUrl, Exception JavaDoc cause) {
94         return XMLParseException.getXMLParseException(new Object JavaDoc[] {baseUrl, schemaUrl}, cause, EXCEPTION_SETTING_SCHEMA_SOURCE);
95     }
96
97     /*
98      * INTERNAL:
99      */

100     private static XMLParseException getXMLParseException(Object JavaDoc[] args, Exception JavaDoc cause, int errorCode) {
101         XMLParseException parseException = new XMLParseException(ExceptionMessageGenerator.buildMessage(XMLParseException.class, errorCode, args), cause);
102         parseException.setErrorCode(errorCode);
103         return parseException;
104     }
105 }
106
Popular Tags