1 21 package oracle.toplink.essentials.platform.xml; 23 24 import java.io.File ; 25 import java.io.IOException ; 26 import java.net.URL ; 27 import org.xml.sax.SAXParseException ; 28 import oracle.toplink.essentials.exceptions.TopLinkException; 29 import oracle.toplink.essentials.exceptions.i18n.ExceptionMessageGenerator; 30 31 public class XMLPlatformException extends TopLinkException { 32 public static final int XML_PLATFORM_CLASS_NOT_FOUND = 27001; 33 public static final int XML_PLATFORM_COULD_NOT_INSTANTIATE = 27002; 34 public static final int XML_PLATFORM_COULD_NOT_CREATE_DOCUMENT = 27003; 35 public static final int XML_PLATFORM_INVALID_XPATH = 27004; 36 public static final int XML_PLATFORM_VALIDATION_EXCEPTION = 27005; 37 public static final int XML_PLATFORM_PARSER_ERROR_RESOLVING_XML_SCHEMA = 27006; 38 public static final int XML_PLATFORM_PARSE_EXCEPTION = 27101; 39 public static final int XML_PLATFORM_PARSER_FILE_NOT_FOUND_EXCEPTION = 27102; 40 public static final int XML_PLATFORM_PARSER_SAX_PARSE_EXCEPTION = 27103; 41 public static final int XML_PLATFORM_TRANSFORM_EXCEPTION = 27201; 42 public static final int XML_PLATFORM_INVALID_TYPE = 27202; 43 44 protected XMLPlatformException(String message) { 45 super(message); 46 } 47 48 public static XMLPlatformException xmlPlatformClassNotFound(String xmlPlatformClassName, Exception nestedException) { 49 Object [] args = { xmlPlatformClassName }; 50 int errorCode = XML_PLATFORM_CLASS_NOT_FOUND; 51 XMLPlatformException exception = new XMLPlatformException(ExceptionMessageGenerator.buildMessage(XMLPlatformException.class, errorCode, args)); 52 exception.setErrorCode(errorCode); 53 exception.setInternalException(nestedException); 54 return exception; 55 } 56 57 public static XMLPlatformException xmlPlatformCouldNotInstantiate(String xmlPlatformClassName, Exception nestedException) { 58 Object [] args = { xmlPlatformClassName }; 59 int errorCode = XML_PLATFORM_COULD_NOT_INSTANTIATE; 60 XMLPlatformException exception = new XMLPlatformException(ExceptionMessageGenerator.buildMessage(XMLPlatformException.class, errorCode, args)); 61 exception.setErrorCode(errorCode); 62 exception.setInternalException(nestedException); 63 return exception; 64 } 65 66 public static XMLPlatformException xmlPlatformCouldNotCreateDocument(Exception nestedException) { 67 Object [] args = { }; 68 int errorCode = XML_PLATFORM_COULD_NOT_CREATE_DOCUMENT; 69 XMLPlatformException exception = new XMLPlatformException(ExceptionMessageGenerator.buildMessage(XMLPlatformException.class, errorCode, args)); 70 exception.setErrorCode(errorCode); 71 return exception; 72 } 73 74 public static XMLPlatformException xmlPlatformInvalidXPath(Exception nestedException) { 75 Object [] args = { }; 76 int errorCode = XML_PLATFORM_INVALID_XPATH; 77 XMLPlatformException exception = new XMLPlatformException(ExceptionMessageGenerator.buildMessage(XMLPlatformException.class, errorCode, args)); 78 exception.setErrorCode(errorCode); 79 exception.setInternalException(nestedException); 80 return exception; 81 } 82 83 public static XMLPlatformException xmlPlatformValidationException(Exception nestedException) { 84 Object [] args = { }; 85 int errorCode = XML_PLATFORM_VALIDATION_EXCEPTION; 86 XMLPlatformException exception = new XMLPlatformException(ExceptionMessageGenerator.buildMessage(XMLPlatformException.class, errorCode, args)); 87 exception.setErrorCode(errorCode); 88 exception.setInternalException(nestedException); 89 return exception; 90 } 91 92 95 public static XMLPlatformException xmlPlatformValidationException(String errorMessage) { 96 int errorCode = XML_PLATFORM_VALIDATION_EXCEPTION; 97 XMLPlatformException exception = new XMLPlatformException(errorMessage); 98 exception.setErrorCode(errorCode); 99 return exception; 100 } 101 102 107 public static XMLPlatformException xmlPlatformInvalidTypeException(int type) { 108 Object [] args = { new Integer (type) }; 109 int errorCode = XML_PLATFORM_INVALID_TYPE; 110 XMLPlatformException exception = new XMLPlatformException(ExceptionMessageGenerator.buildMessage(XMLPlatformException.class, errorCode, args)); 111 exception.setErrorCode(errorCode); 112 return exception; 113 } 114 115 public static XMLPlatformException xmlPlatformParseException(Exception nestedException) { 116 Object [] args = { }; 117 int errorCode = XML_PLATFORM_PARSE_EXCEPTION; 118 XMLPlatformException exception = new XMLPlatformException(ExceptionMessageGenerator.buildMessage(XMLPlatformException.class, errorCode, args)); 119 exception.setErrorCode(errorCode); 120 exception.setInternalException(nestedException); 121 return exception; 122 } 123 124 public static XMLPlatformException xmlPlatformFileNotFoundException(File file, IOException nestedException) { 125 Object [] args = { file.getAbsolutePath() }; 126 int errorCode = XML_PLATFORM_PARSER_FILE_NOT_FOUND_EXCEPTION; 127 XMLPlatformException exception = new XMLPlatformException(ExceptionMessageGenerator.buildMessage(XMLPlatformException.class, errorCode, args)); 128 exception.setErrorCode(errorCode); 129 exception.setInternalException(nestedException); 130 return exception; 131 } 132 133 public static XMLPlatformException xmlPlatformSAXParseException(SAXParseException nestedException) { 134 Object [] args = { new Integer (nestedException.getLineNumber()), nestedException.getSystemId(), nestedException.getMessage() }; 135 int errorCode = XML_PLATFORM_PARSER_SAX_PARSE_EXCEPTION; 136 XMLPlatformException exception = new XMLPlatformException(ExceptionMessageGenerator.buildMessage(XMLPlatformException.class, errorCode, args)); 137 exception.setErrorCode(errorCode); 138 exception.setInternalException(nestedException); 139 return exception; 140 } 141 142 public static XMLPlatformException xmlPlatformErrorResolvingXMLSchema(URL url, Exception nestedException) { 143 Object [] args = { url }; 144 int errorCode = XML_PLATFORM_PARSER_ERROR_RESOLVING_XML_SCHEMA; 145 XMLPlatformException exception = new XMLPlatformException(ExceptionMessageGenerator.buildMessage(XMLPlatformException.class, errorCode, args)); 146 exception.setErrorCode(errorCode); 147 exception.setInternalException(nestedException); 148 return exception; 149 } 150 151 public static XMLPlatformException xmlPlatformErrorResolvingXMLSchemas(Object [] schemas, Exception nestedException) { 152 Object [] args = { }; 153 int errorCode = XML_PLATFORM_PARSER_ERROR_RESOLVING_XML_SCHEMA; 154 XMLPlatformException exception = new XMLPlatformException(ExceptionMessageGenerator.buildMessage(XMLPlatformException.class, errorCode, args)); 155 exception.setErrorCode(errorCode); 156 exception.setInternalException(nestedException); 157 return exception; 158 } 159 160 public static XMLPlatformException xmlPlatformTransformException(Exception nestedException) { 161 Object [] args = { }; 162 int errorCode = XML_PLATFORM_TRANSFORM_EXCEPTION; 163 XMLPlatformException exception = new XMLPlatformException(ExceptionMessageGenerator.buildMessage(XMLPlatformException.class, errorCode, args)); 164 exception.setErrorCode(errorCode); 165 exception.setInternalException(nestedException); 166 return exception; 167 } 168 } 169 | Popular Tags |