1 16 19 package com.sun.org.apache.xpath.internal.res; 20 21 import java.util.ListResourceBundle ; 22 23 import com.sun.org.apache.xml.internal.res.XMLMessages; 24 25 29 public class XPATHMessages extends XMLMessages 30 { 31 32 private static ListResourceBundle XPATHBundle = null; 33 34 35 private static final String XPATH_ERROR_RESOURCES = 36 "com.sun.org.apache.xpath.internal.res.XPATHErrorResources"; 37 38 48 public static final String createXPATHMessage(String msgKey, Object args[]) { 50 if (XPATHBundle == null) 51 XPATHBundle = loadResourceBundle(XPATH_ERROR_RESOURCES); 52 53 if (XPATHBundle != null) 54 { 55 return createXPATHMsg(XPATHBundle, msgKey, args); 56 } 57 else 58 return "Could not load any resource bundles."; 59 } 60 61 71 public static final String createXPATHWarning(String msgKey, Object args[]) { 73 if (XPATHBundle == null) 74 XPATHBundle = loadResourceBundle(XPATH_ERROR_RESOURCES); 75 76 if (XPATHBundle != null) 77 { 78 return createXPATHMsg(XPATHBundle, msgKey, args); 79 } 80 else 81 return "Could not load any resource bundles."; 82 } 83 84 97 public static final String createXPATHMsg(ListResourceBundle fResourceBundle, 98 String msgKey, Object args[]) { 100 101 String fmsg = null; 102 boolean throwex = false; 103 String msg = null; 104 105 if (msgKey != null) 106 msg = fResourceBundle.getString(msgKey); 107 108 if (msg == null) 109 { 110 msg = fResourceBundle.getString(XPATHErrorResources.BAD_CODE); 111 throwex = true; 112 } 113 114 if (args != null) 115 { 116 try 117 { 118 119 int n = args.length; 123 124 for (int i = 0; i < n; i++) 125 { 126 if (null == args[i]) 127 args[i] = ""; 128 } 129 130 fmsg = java.text.MessageFormat.format(msg, args); 131 } 132 catch (Exception e) 133 { 134 fmsg = fResourceBundle.getString(XPATHErrorResources.FORMAT_FAILED); 135 fmsg += " " + msg; 136 } 137 } 138 else 139 fmsg = msg; 140 141 if (throwex) 142 { 143 throw new RuntimeException (fmsg); 144 } 145 146 return fmsg; 147 } 148 149 } 150 | Popular Tags |