1 16 17 package org.apache.xerces.impl.dv; 18 19 import java.util.ResourceBundle ; 20 import java.util.PropertyResourceBundle ; 21 import java.util.MissingResourceException ; 22 23 35 public class DatatypeException extends Exception { 36 37 38 static final long serialVersionUID = 1940805832730465578L; 39 40 protected String key; 42 protected Object [] args; 43 44 51 public DatatypeException(String key, Object [] args) { 52 super(key); 53 this.key = key; 54 this.args = args; 55 } 56 57 62 public String getKey() { 63 return key; 64 } 65 66 71 public Object [] getArgs() { 72 return args; 73 } 74 75 82 public String getMessage() { 83 ResourceBundle resourceBundle = null; 84 resourceBundle = PropertyResourceBundle.getBundle("org.apache.xerces.impl.msg.XMLSchemaMessages"); 85 if (resourceBundle == null) 86 throw new MissingResourceException ("Property file not found!", "org.apache.xerces.impl.msg.XMLSchemaMessages", key); 87 88 String msg = resourceBundle.getString(key); 89 if (msg == null) { 90 msg = resourceBundle.getString("BadMessageKey"); 91 throw new MissingResourceException (msg, "org.apache.xerces.impl.msg.XMLSchemaMessages", key); 92 } 93 94 if (args != null) { 95 try { 96 msg = java.text.MessageFormat.format(msg, args); 97 } catch (Exception e) { 98 msg = resourceBundle.getString("FormatFailed"); 99 msg += " " + resourceBundle.getString(key); 100 } 101 } 102 103 return msg; 104 } 105 } 106 | Popular Tags |