1 20 21 25 26 package org.ozoneDB.xml.dom; 27 28 import org.w3c.dom.*; 29 30 31 44 public final class DOMExceptionImpl extends DOMException { 45 46 public final static short PDOM_ERR = 11; 47 48 49 55 public DOMExceptionImpl( short code ) { 56 this( code, null ); 57 } 58 59 60 67 public DOMExceptionImpl( short code, String message ) { 68 super( code, makeMessage( code, message ) ); 69 } 70 71 72 public String toString() { 73 return "DOMException(" + super.code + "): " + getMessage(); 74 } 75 76 77 86 private static String makeMessage( short code, String message ) { 87 String codeText; 88 89 switch (code) { 90 case INDEX_SIZE_ERR: 91 codeText = "Index or size is negative or greater than the allowed value."; 92 break; 93 case HIERARCHY_REQUEST_ERR: 94 codeText = "Node is inserted somewhere it doesn't belong."; 95 break; 96 case WRONG_DOCUMENT_ERR: 97 codeText = "Node is used in a different document than the one that created it."; 98 break; 99 case INVALID_CHARACTER_ERR: 100 codeText = "An invalid character is specified, such as in a name."; 101 break; 102 case NO_DATA_ALLOWED_ERR: 103 codeText = "Node does not support data."; 104 break; 105 case NO_MODIFICATION_ALLOWED_ERR: 106 codeText = "Attempt made to modify an pbject where modification not allowed."; 107 break; 108 case NOT_FOUND_ERR: 109 codeText = "Attempt to reference a node in a context where it does not exist."; 110 break; 111 case NOT_SUPPORTED_ERR: 112 codeText = "Implementation does not support the type of object requested."; 113 break; 114 case INUSE_ATTRIBUTE_ERR: 115 codeText = "An attempt to add an attribute that is already inuse elsewhere."; 116 break; 117 default: 118 codeText = "Exception reason is unspecified."; 119 break; 120 } 121 codeText = "DOMException: " + codeText + " (code " + code + ")"; 122 if (message != null && message.length() > 0) { 123 codeText = codeText + "\n" + message; 124 } 125 return codeText; 126 } 127 128 } 129 | Popular Tags |