1 21 package oracle.toplink.essentials.exceptions; 23 24 import java.io.File ; 25 import java.net.URL ; 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 41 public XMLParseException() { 42 super(); 43 } 44 45 49 protected XMLParseException(String message) { 50 super(message); 51 } 52 53 57 protected XMLParseException(String message, Throwable internalException) { 58 super(message); 59 setInternalException(internalException); 60 } 61 62 65 public static XMLParseException exceptionCreatingDocumentBuilder(String xmlDocument, Exception cause) { 66 return XMLParseException.getXMLParseException(new Object [] {xmlDocument}, cause, EXCEPTION_CREATING_DOCUMENT_BUILDER); 67 } 68 69 72 public static XMLParseException exceptionCreatingSAXParser(URL url, Exception cause) { 73 return XMLParseException.getXMLParseException(new Object [] {url}, cause, EXCEPTION_CREATING_SAX_PARSER); 74 } 75 76 79 public static XMLParseException exceptionCreatingXMLReader(URL url, Exception cause) { 80 return XMLParseException.getXMLParseException(new Object [] {url}, cause, EXCEPTION_CREATING_XML_READER); 81 } 82 83 86 public static XMLParseException exceptionReadingXMLDocument(String xmlDocument, Exception cause) { 87 return XMLParseException.getXMLParseException(new Object [] {xmlDocument}, cause, EXCEPTION_READING_XML_DOCUMENT); 88 } 89 90 93 public static XMLParseException exceptionSettingSchemaSource(URL baseUrl, URL schemaUrl, Exception cause) { 94 return XMLParseException.getXMLParseException(new Object [] {baseUrl, schemaUrl}, cause, EXCEPTION_SETTING_SCHEMA_SOURCE); 95 } 96 97 100 private static XMLParseException getXMLParseException(Object [] args, Exception 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 |