Thu, 15 Jan 2009 18:06:36 -0800
6794520: MessageRetriever should be upgraded to use varargs Object...
Reviewed-by: bpatel
1.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/MessageRetriever.java Thu Jan 15 17:21:11 2009 -0800 1.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/MessageRetriever.java Thu Jan 15 18:06:36 2009 -0800 1.3 @@ -81,46 +81,14 @@ 1.4 } 1.5 1.6 /** 1.7 - * get and format message string from resource 1.8 - * 1.9 - * @param key selects message from resource 1.10 - */ 1.11 - public String getText(String key) { 1.12 - return getText(key, (String)null); 1.13 - } 1.14 - 1.15 - /** 1.16 * Get and format message string from resource 1.17 * 1.18 * @param key selects message from resource 1.19 - * @param a1 Argument, to be repalced in the message. 1.20 - */ 1.21 - public String getText(String key, String a1) { 1.22 - return getText(key, a1, null); 1.23 - } 1.24 - 1.25 - /** 1.26 - * Get and format message string from resource 1.27 - * 1.28 - * @param key selects message from resource 1.29 - * @param a1 first argument to be replaced in the message. 1.30 - * @param a2 second argument to be replaced in the message. 1.31 - */ 1.32 - public String getText(String key, String a1, String a2) { 1.33 - return getText(key, a1, a2, null); 1.34 - } 1.35 - 1.36 - /** 1.37 - * Get and format message string from resource 1.38 - * 1.39 - * @param key selects message from resource 1.40 - * @param a1 first argument to be replaced in the message. 1.41 - * @param a2 second argument to be replaced in the message. 1.42 - * @param a3 third argument to be replaced in the message. 1.43 + * @param args arguments to be replaced in the message. 1.44 * @throws MissingResourceException when the key does not 1.45 * exist in the properties file. 1.46 */ 1.47 - public String getText(String key, String a1, String a2, String a3) throws MissingResourceException { 1.48 + public String getText(String key, Object... args) throws MissingResourceException { 1.49 if (messageRB == null) { 1.50 try { 1.51 messageRB = ResourceBundle.getBundle(resourcelocation); 1.52 @@ -130,7 +98,7 @@ 1.53 } 1.54 } 1.55 String message = messageRB.getString(key); 1.56 - return MessageFormat.format(message, a1, a2, a3); 1.57 + return MessageFormat.format(message, args); 1.58 } 1.59 1.60 /** 1.61 @@ -195,87 +163,20 @@ 1.62 * 1.63 * @param pos the position of the source 1.64 * @param key selects message from resource 1.65 + * @param args arguments to be replaced in the message. 1.66 */ 1.67 - public void error(SourcePosition pos, String key) { 1.68 - printError(pos, getText(key)); 1.69 + public void error(SourcePosition pos, String key, Object... args) { 1.70 + printError(pos, getText(key, args)); 1.71 } 1.72 1.73 /** 1.74 * Print error message, increment error count. 1.75 * 1.76 * @param key selects message from resource 1.77 + * @param args arguments to be replaced in the message. 1.78 */ 1.79 - public void error(String key) { 1.80 - printError(getText(key)); 1.81 - } 1.82 - 1.83 - /** 1.84 - * Print error message, increment error count. 1.85 - * 1.86 - * @param pos the position of the source 1.87 - * @param key selects message from resource 1.88 - * @param a1 first argument to be replaced in the message. 1.89 - */ 1.90 - public void error(SourcePosition pos, String key, String a1) { 1.91 - printError(pos, getText(key, a1)); 1.92 - } 1.93 - 1.94 - /** 1.95 - * Print error message, increment error count. 1.96 - * 1.97 - * @param key selects message from resource 1.98 - * @param a1 first argument to be replaced in the message. 1.99 - */ 1.100 - public void error(String key, String a1) { 1.101 - printError(getText(key, a1)); 1.102 - } 1.103 - 1.104 - /** 1.105 - * Print error message, increment error count. 1.106 - * 1.107 - * @param pos the position of the source 1.108 - * @param key selects message from resource 1.109 - * @param a1 first argument to be replaced in the message. 1.110 - * @param a2 second argument to be replaced in the message. 1.111 - */ 1.112 - public void error(SourcePosition pos, String key, String a1, String a2) { 1.113 - printError(pos, getText(key, a1, a2)); 1.114 - } 1.115 - 1.116 - /** 1.117 - * Print error message, increment error count. 1.118 - * 1.119 - * @param key selects message from resource 1.120 - * @param a1 first argument to be replaced in the message. 1.121 - * @param a2 second argument to be replaced in the message. 1.122 - */ 1.123 - public void error(String key, String a1, String a2) { 1.124 - printError(getText(key, a1, a2)); 1.125 - } 1.126 - 1.127 - /** 1.128 - * Print error message, increment error count. 1.129 - * 1.130 - * @param pos the position of the source 1.131 - * @param key selects message from resource 1.132 - * @param a1 first argument to be replaced in the message. 1.133 - * @param a2 second argument to be replaced in the message. 1.134 - * @param a3 third argument to be replaced in the message. 1.135 - */ 1.136 - public void error(SourcePosition pos, String key, String a1, String a2, String a3) { 1.137 - printError(pos, getText(key, a1, a2, a3)); 1.138 - } 1.139 - 1.140 - /** 1.141 - * Print error message, increment error count. 1.142 - * 1.143 - * @param key selects message from resource 1.144 - * @param a1 first argument to be replaced in the message. 1.145 - * @param a2 second argument to be replaced in the message. 1.146 - * @param a3 third argument to be replaced in the message. 1.147 - */ 1.148 - public void error(String key, String a1, String a2, String a3) { 1.149 - printError(getText(key, a1, a2, a3)); 1.150 + public void error(String key, Object... args) { 1.151 + printError(getText(key, args)); 1.152 } 1.153 1.154 /** 1.155 @@ -283,87 +184,20 @@ 1.156 * 1.157 * @param pos the position of the source 1.158 * @param key selects message from resource 1.159 + * @param args arguments to be replaced in the message. 1.160 */ 1.161 - public void warning(SourcePosition pos, String key) { 1.162 - printWarning(pos, getText(key)); 1.163 + public void warning(SourcePosition pos, String key, Object... args) { 1.164 + printWarning(pos, getText(key, args)); 1.165 } 1.166 1.167 /** 1.168 * Print warning message, increment warning count. 1.169 * 1.170 * @param key selects message from resource 1.171 + * @param args arguments to be replaced in the message. 1.172 */ 1.173 - public void warning(String key) { 1.174 - printWarning(getText(key)); 1.175 - } 1.176 - 1.177 - /** 1.178 - * Print warning message, increment warning count. 1.179 - * 1.180 - * @param pos the position of the source 1.181 - * @param key selects message from resource 1.182 - * @param a1 first argument to be replaced in the message. 1.183 - */ 1.184 - public void warning(SourcePosition pos, String key, String a1) { 1.185 - printWarning(pos, getText(key, a1)); 1.186 - } 1.187 - 1.188 - /** 1.189 - * Print warning message, increment warning count. 1.190 - * 1.191 - * @param key selects message from resource 1.192 - * @param a1 first argument to be replaced in the message. 1.193 - */ 1.194 - public void warning(String key, String a1) { 1.195 - printWarning(getText(key, a1)); 1.196 - } 1.197 - 1.198 - /** 1.199 - * Print warning message, increment warning count. 1.200 - * 1.201 - * @param pos the position of the source 1.202 - * @param key selects message from resource 1.203 - * @param a1 first argument to be replaced in the message. 1.204 - * @param a2 second argument to be replaced in the message. 1.205 - */ 1.206 - public void warning(SourcePosition pos, String key, String a1, String a2) { 1.207 - printWarning(pos, getText(key, a1, a2)); 1.208 - } 1.209 - 1.210 - /** 1.211 - * Print warning message, increment warning count. 1.212 - * 1.213 - * @param key selects message from resource 1.214 - * @param a1 first argument to be replaced in the message. 1.215 - * @param a2 second argument to be replaced in the message. 1.216 - */ 1.217 - public void warning(String key, String a1, String a2) { 1.218 - printWarning(getText(key, a1, a2)); 1.219 - } 1.220 - 1.221 - /** 1.222 - * Print warning message, increment warning count. 1.223 - * 1.224 - * @param pos the position of the source 1.225 - * @param key selects message from resource 1.226 - * @param a1 first argument to be replaced in the message. 1.227 - * @param a2 second argument to be replaced in the message. 1.228 - * @param a3 third argument to be replaced in the message. 1.229 - */ 1.230 - public void warning(SourcePosition pos, String key, String a1, String a2, String a3) { 1.231 - printWarning(pos, getText(key, a1, a2, a3)); 1.232 - } 1.233 - 1.234 - /** 1.235 - * Print warning message, increment warning count. 1.236 - * 1.237 - * @param key selects message from resource 1.238 - * @param a1 first argument to be replaced in the message. 1.239 - * @param a2 second argument to be replaced in the message. 1.240 - * @param a3 third argument to be replaced in the message. 1.241 - */ 1.242 - public void warning(String key, String a1, String a2, String a3) { 1.243 - printWarning(getText(key, a1, a2, a3)); 1.244 + public void warning(String key, Object... args) { 1.245 + printWarning(getText(key, args)); 1.246 } 1.247 1.248 /** 1.249 @@ -371,85 +205,19 @@ 1.250 * 1.251 * @param pos the position of the source 1.252 * @param key selects message from resource 1.253 + * @param args arguments to be replaced in the message. 1.254 */ 1.255 - public void notice(SourcePosition pos, String key) { 1.256 - printNotice(pos, getText(key)); 1.257 + public void notice(SourcePosition pos, String key, Object... args) { 1.258 + printNotice(pos, getText(key, args)); 1.259 } 1.260 1.261 /** 1.262 * Print a message. 1.263 * 1.264 * @param key selects message from resource 1.265 + * @param args arguments to be replaced in the message. 1.266 */ 1.267 - public void notice(String key) { 1.268 - printNotice(getText(key)); 1.269 - } 1.270 - 1.271 - /** 1.272 - * Print a message. 1.273 - * @param pos the position of the source 1.274 - * @param key selects message from resource 1.275 - * @param a1 first argument to be replaced in the message. 1.276 - */ 1.277 - public void notice(SourcePosition pos, String key, String a1) { 1.278 - printNotice(pos, getText(key, a1)); 1.279 - } 1.280 - 1.281 - /** 1.282 - * Print a message. 1.283 - * 1.284 - * @param key selects message from resource 1.285 - * @param a1 first argument to be replaced in the message. 1.286 - */ 1.287 - public void notice(String key, String a1) { 1.288 - printNotice(getText(key, a1)); 1.289 - } 1.290 - 1.291 - /** 1.292 - * Print a message. 1.293 - * 1.294 - * @param pos the position of the source 1.295 - * @param key selects message from resource 1.296 - * @param a1 first argument to be replaced in the message. 1.297 - * @param a2 second argument to be replaced in the message. 1.298 - */ 1.299 - public void notice(SourcePosition pos, String key, String a1, String a2) { 1.300 - printNotice(pos, getText(key, a1, a2)); 1.301 - } 1.302 - 1.303 - /** 1.304 - * Print a message. 1.305 - * 1.306 - * @param key selects message from resource 1.307 - * @param a1 first argument to be replaced in the message. 1.308 - * @param a2 second argument to be replaced in the message. 1.309 - */ 1.310 - public void notice(String key, String a1, String a2) { 1.311 - printNotice(getText(key, a1, a2)); 1.312 - } 1.313 - 1.314 - /** 1.315 - * Print a message. 1.316 - * 1.317 - * @param pos the position of the source 1.318 - * @param key selects message from resource 1.319 - * @param a1 first argument to be replaced in the message. 1.320 - * @param a2 second argument to be replaced in the message. 1.321 - * @param a3 third argument to be replaced in the message. 1.322 - */ 1.323 - public void notice(SourcePosition pos, String key, String a1, String a2, String a3) { 1.324 - printNotice(pos, getText(key, a1, a2, a3)); 1.325 - } 1.326 - 1.327 - /** 1.328 - * Print a message. 1.329 - * 1.330 - * @param key selects message from resource 1.331 - * @param a1 first argument to be replaced in the message. 1.332 - * @param a2 second argument to be replaced in the message. 1.333 - * @param a3 third argument to be replaced in the message. 1.334 - */ 1.335 - public void notice(String key, String a1, String a2, String a3) { 1.336 - printNotice(getText(key, a1, a2, a3)); 1.337 + public void notice(String key, Object... args) { 1.338 + printNotice(getText(key, args)); 1.339 } 1.340 }
2.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java Thu Jan 15 17:21:11 2009 -0800 2.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java Thu Jan 15 18:06:36 2009 -0800 2.3 @@ -599,7 +599,6 @@ 2.4 } 2.5 if (docencoding == null) { 2.6 OutputStreamWriter oswriter = new OutputStreamWriter(fos); 2.7 - docencoding = oswriter.getEncoding(); 2.8 return oswriter; 2.9 } else { 2.10 return new OutputStreamWriter(fos, docencoding);