6794520: MessageRetriever should be upgraded to use varargs Object...
authorjjg
Thu, 15 Jan 2009 18:06:36 -0800
changeset 1864 c17be9084212
parent 1863 e5de9abc0eb1
child 1865 aeefb02117a8
6794520: MessageRetriever should be upgraded to use varargs Object... Reviewed-by: bpatel
langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/MessageRetriever.java
langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/MessageRetriever.java	Thu Jan 15 17:21:11 2009 -0800
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/MessageRetriever.java	Thu Jan 15 18:06:36 2009 -0800
@@ -81,46 +81,14 @@
     }
 
     /**
-     * get and format message string from resource
-     *
-     * @param key selects message from resource
-     */
-    public String getText(String key) {
-        return getText(key, (String)null);
-    }
-
-    /**
      * Get and format message string from resource
      *
      * @param key selects message from resource
-     * @param a1 Argument, to be repalced in the message.
-     */
-    public String getText(String key, String a1) {
-        return getText(key, a1, null);
-    }
-
-    /**
-     * Get and format message string from resource
-     *
-     * @param key selects message from resource
-     * @param a1 first argument to be replaced in the message.
-     * @param a2 second argument to be replaced in the message.
-     */
-    public String getText(String key, String a1, String a2) {
-        return getText(key, a1, a2, null);
-    }
-
-    /**
-     * Get and format message string from resource
-     *
-     * @param key selects message from resource
-     * @param a1 first argument to be replaced in the message.
-     * @param a2 second argument to be replaced in the message.
-     * @param a3 third argument to be replaced in the message.
+     * @param args arguments to be replaced in the message.
      * @throws MissingResourceException when the key does not
      * exist in the properties file.
      */
-    public String getText(String key, String a1, String a2, String a3) throws MissingResourceException {
+    public String getText(String key, Object... args) throws MissingResourceException {
         if (messageRB == null) {
             try {
                 messageRB = ResourceBundle.getBundle(resourcelocation);
@@ -130,7 +98,7 @@
             }
         }
         String message = messageRB.getString(key);
-        return MessageFormat.format(message, a1, a2, a3);
+        return MessageFormat.format(message, args);
     }
 
     /**
@@ -195,127 +163,20 @@
      *
      * @param pos the position of the source
      * @param key selects message from resource
-     */
-    public void error(SourcePosition pos, String key) {
-        printError(pos, getText(key));
-    }
-
-    /**
-     * Print error message, increment error count.
-     *
-     * @param key selects message from resource
-     */
-    public void error(String key) {
-        printError(getText(key));
-    }
-
-    /**
-     * Print error message, increment error count.
-     *
-     * @param pos the position of the source
-     * @param key selects message from resource
-     * @param a1 first argument to be replaced in the message.
+     * @param args arguments to be replaced in the message.
      */
-    public void error(SourcePosition pos, String key, String a1) {
-        printError(pos, getText(key, a1));
-    }
-
-    /**
-     * Print error message, increment error count.
-     *
-     * @param key selects message from resource
-     * @param a1 first argument to be replaced in the message.
-     */
-    public void error(String key, String a1) {
-        printError(getText(key, a1));
-    }
-
-    /**
-     * Print error message, increment error count.
-     *
-     * @param pos the position of the source
-     * @param key selects message from resource
-     * @param a1 first argument to be replaced in the message.
-     * @param a2 second argument to be replaced in the message.
-     */
-    public void error(SourcePosition pos, String key, String a1, String a2) {
-        printError(pos, getText(key, a1, a2));
+    public void error(SourcePosition pos, String key, Object... args) {
+        printError(pos, getText(key, args));
     }
 
     /**
      * Print error message, increment error count.
      *
      * @param key selects message from resource
-     * @param a1 first argument to be replaced in the message.
-     * @param a2 second argument to be replaced in the message.
-     */
-    public void error(String key, String a1, String a2) {
-        printError(getText(key, a1, a2));
-    }
-
-    /**
-     * Print error message, increment error count.
-     *
-     * @param pos the position of the source
-     * @param key selects message from resource
-     * @param a1 first argument to be replaced in the message.
-     * @param a2 second argument to be replaced in the message.
-     * @param a3 third argument to be replaced in the message.
-     */
-    public void error(SourcePosition pos, String key, String a1, String a2, String a3) {
-        printError(pos, getText(key, a1, a2, a3));
-    }
-
-    /**
-     * Print error message, increment error count.
-     *
-     * @param key selects message from resource
-     * @param a1 first argument to be replaced in the message.
-     * @param a2 second argument to be replaced in the message.
-     * @param a3 third argument to be replaced in the message.
+     * @param args arguments to be replaced in the message.
      */
-    public void error(String key, String a1, String a2, String a3) {
-        printError(getText(key, a1, a2, a3));
-    }
-
-    /**
-     * Print warning message, increment warning count.
-     *
-     * @param pos the position of the source
-     * @param key selects message from resource
-     */
-    public void warning(SourcePosition pos, String key) {
-        printWarning(pos, getText(key));
-    }
-
-    /**
-     * Print warning message, increment warning count.
-     *
-     * @param key selects message from resource
-     */
-    public void warning(String key) {
-        printWarning(getText(key));
-    }
-
-    /**
-     * Print warning message, increment warning count.
-     *
-     * @param pos the position of the source
-     * @param key selects message from resource
-     * @param a1 first argument to be replaced in the message.
-     */
-    public void warning(SourcePosition pos, String key, String a1) {
-        printWarning(pos, getText(key, a1));
-    }
-
-    /**
-     * Print warning message, increment warning count.
-     *
-     * @param key selects message from resource
-     * @param a1 first argument to be replaced in the message.
-     */
-    public void warning(String key, String a1) {
-        printWarning(getText(key, a1));
+    public void error(String key, Object... args) {
+        printError(getText(key, args));
     }
 
     /**
@@ -323,47 +184,20 @@
      *
      * @param pos the position of the source
      * @param key selects message from resource
-     * @param a1 first argument to be replaced in the message.
-     * @param a2 second argument to be replaced in the message.
+     * @param args arguments to be replaced in the message.
      */
-    public void warning(SourcePosition pos, String key, String a1, String a2) {
-        printWarning(pos, getText(key, a1, a2));
+    public void warning(SourcePosition pos, String key, Object... args) {
+        printWarning(pos, getText(key, args));
     }
 
     /**
      * Print warning message, increment warning count.
      *
      * @param key selects message from resource
-     * @param a1 first argument to be replaced in the message.
-     * @param a2 second argument to be replaced in the message.
+     * @param args arguments to be replaced in the message.
      */
-    public void warning(String key, String a1, String a2) {
-        printWarning(getText(key, a1, a2));
-    }
-
-    /**
-     * Print warning message, increment warning count.
-     *
-     * @param pos the position of the source
-     * @param key selects message from resource
-     * @param a1 first argument to be replaced in the message.
-     * @param a2 second argument to be replaced in the message.
-     * @param a3 third argument to be replaced in the message.
-     */
-    public void warning(SourcePosition pos, String key, String a1, String a2, String a3) {
-        printWarning(pos, getText(key, a1, a2, a3));
-    }
-
-    /**
-     * Print warning message, increment warning count.
-     *
-     * @param key selects message from resource
-     * @param a1 first argument to be replaced in the message.
-     * @param a2 second argument to be replaced in the message.
-     * @param a3 third argument to be replaced in the message.
-     */
-    public void warning(String key, String a1, String a2, String a3) {
-        printWarning(getText(key, a1, a2, a3));
+    public void warning(String key, Object... args) {
+        printWarning(getText(key, args));
     }
 
     /**
@@ -371,85 +205,19 @@
      *
      * @param pos the position of the source
      * @param key selects message from resource
-     */
-    public void notice(SourcePosition pos, String key) {
-        printNotice(pos, getText(key));
-    }
-
-    /**
-     * Print a message.
-     *
-     * @param key selects message from resource
+     * @param args arguments to be replaced in the message.
      */
-    public void notice(String key) {
-        printNotice(getText(key));
-    }
-
-    /**
-     * Print a message.
-     * @param pos the position of the source
-     * @param key selects message from resource
-     * @param a1 first argument to be replaced in the message.
-     */
-    public void notice(SourcePosition pos, String key, String a1) {
-        printNotice(pos, getText(key, a1));
+    public void notice(SourcePosition pos, String key, Object... args) {
+        printNotice(pos, getText(key, args));
     }
 
     /**
      * Print a message.
      *
      * @param key selects message from resource
-     * @param a1 first argument to be replaced in the message.
-     */
-    public void notice(String key, String a1) {
-        printNotice(getText(key, a1));
-    }
-
-    /**
-     * Print a message.
-     *
-     * @param pos the position of the source
-     * @param key selects message from resource
-     * @param a1 first argument to be replaced in the message.
-     * @param a2 second argument to be replaced in the message.
-     */
-    public void notice(SourcePosition pos, String key, String a1, String a2) {
-        printNotice(pos, getText(key, a1, a2));
-    }
-
-    /**
-     * Print a message.
-     *
-     * @param key selects message from resource
-     * @param a1 first argument to be replaced in the message.
-     * @param a2 second argument to be replaced in the message.
+     * @param args arguments to be replaced in the message.
      */
-    public void notice(String key, String a1, String a2) {
-        printNotice(getText(key, a1, a2));
-    }
-
-    /**
-     * Print a message.
-     *
-     * @param pos the position of the source
-     * @param key selects message from resource
-     * @param a1 first argument to be replaced in the message.
-     * @param a2 second argument to be replaced in the message.
-     * @param a3 third argument to be replaced in the message.
-     */
-    public void notice(SourcePosition pos, String key, String a1, String a2, String a3) {
-        printNotice(pos, getText(key, a1, a2, a3));
-    }
-
-    /**
-     * Print a message.
-     *
-     * @param key selects message from resource
-     * @param a1 first argument to be replaced in the message.
-     * @param a2 second argument to be replaced in the message.
-     * @param a3 third argument to be replaced in the message.
-     */
-    public void notice(String key, String a1, String a2, String a3) {
-        printNotice(getText(key, a1, a2, a3));
+    public void notice(String key, Object... args) {
+        printNotice(getText(key, args));
     }
 }
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java	Thu Jan 15 17:21:11 2009 -0800
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java	Thu Jan 15 18:06:36 2009 -0800
@@ -599,7 +599,6 @@
         }
         if (docencoding == null) {
             OutputStreamWriter oswriter = new OutputStreamWriter(fos);
-            docencoding = oswriter.getEncoding();
             return oswriter;
         } else {
             return new OutputStreamWriter(fos, docencoding);