diff options
-rw-r--r-- | luni/src/main/java/java/io/Console.java | 39 | ||||
-rw-r--r-- | luni/src/main/java/java/io/PrintStream.java | 31 | ||||
-rw-r--r-- | luni/src/main/java/java/io/PrintWriter.java | 30 | ||||
-rw-r--r-- | luni/src/main/java/java/util/Formatter.java | 4 | ||||
-rw-r--r-- | text/src/main/java/java/text/MessageFormat.java | 23 |
5 files changed, 59 insertions, 68 deletions
diff --git a/luni/src/main/java/java/io/Console.java b/luni/src/main/java/java/io/Console.java index 4bbf4eb..1da92f0 100644 --- a/luni/src/main/java/java/io/Console.java +++ b/luni/src/main/java/java/io/Console.java @@ -67,22 +67,25 @@ public final class Console implements Flushable { * Writes a formatted string to the console using * the specified format string and arguments. * - * @param fmt the format string. - * @param args the arguments used by the formatter. + * @param format the format string (see {@link java.util.Formatter#format}) + * @param args + * the list of arguments passed to the formatter. If there are + * more arguments than required by {@code format}, + * additional arguments are ignored. * @return the console instance. */ - public Console format(String fmt, Object... args) { + public Console format(String format, Object... args) { Formatter f = new Formatter(writer); - f.format(fmt, args); + f.format(format, args); f.flush(); return this; } /** - * Equivalent to {@code format(fmt, args)}. + * Equivalent to {@code format(format, args)}. */ - public Console printf(String fmt, Object... args) { - return format(fmt, args); + public Console printf(String format, Object... args) { + return format(format, args); } /** @@ -112,13 +115,16 @@ public final class Console implements Flushable { * prompt contains {@code %} characters, you must use the format string {@code "%s"} * and pass the actual prompt as a parameter. * - * @param fmt the format string. - * @param args the arguments used by the formatter. + * @param format the format string (see {@link java.util.Formatter#format}) + * @param args + * the list of arguments passed to the formatter. If there are + * more arguments than required by {@code format}, + * additional arguments are ignored. * @return the line, or null at EOF. */ - public String readLine(String fmt, Object... args) { + public String readLine(String format, Object... args) { synchronized (CONSOLE_LOCK) { - format(fmt, args); + format(format, args); return readLine(); } } @@ -154,13 +160,16 @@ public final class Console implements Flushable { * Reads a password from the console. The password will not be echoed to the display. * A formatted prompt is also displayed. * - * @param fmt the format string. - * @param args the arguments used by the formatter. + * @param format the format string (see {@link java.util.Formatter#format}) + * @param args + * the list of arguments passed to the formatter. If there are + * more arguments than required by {@code format}, + * additional arguments are ignored. * @return a character array containing the password, or null at EOF. */ - public char[] readPassword(String fmt, Object... args) { + public char[] readPassword(String format, Object... args) { synchronized (CONSOLE_LOCK) { - format(fmt, args); + format(format, args); return readPassword(); } } diff --git a/luni/src/main/java/java/io/PrintStream.java b/luni/src/main/java/java/io/PrintStream.java index ced2a7f..962b58f 100644 --- a/luni/src/main/java/java/io/PrintStream.java +++ b/luni/src/main/java/java/io/PrintStream.java @@ -314,19 +314,17 @@ public class PrintStream extends FilterOutputStream implements Appendable, * @param l * the locale used in the method. No localization will be applied * if {@code l} is {@code null}. - * @param format - * the format string used for {@link java.util.Formatter#format}. + * @param format the format string (see {@link java.util.Formatter#format}) * @param args * the list of arguments passed to the formatter. If there are - * more arguments than required by the {@code format} string, - * then the additional arguments are ignored. + * more arguments than required by {@code format}, + * additional arguments are ignored. * @return this stream. * @throws IllegalFormatException * if the format string is illegal or incompatible with the * arguments, if there are not enough arguments or if any other * error regarding the format string or arguments is detected. - * @throws NullPointerException - * if {@code format} is {@code null}. + * @throws NullPointerException if {@code format == null} */ public PrintStream format(Locale l, String format, Object... args) { if (format == null) { @@ -341,20 +339,17 @@ public class PrintStream extends FilterOutputStream implements Appendable, * this stream's {@code #format(String, Object...)} method. For the locale, * the default value of the current virtual machine instance is used. * - * @param format - * the format string used for - * {@link java.util.Formatter#format}. + * @param format the format string (see {@link java.util.Formatter#format}) * @param args * the list of arguments passed to the formatter. If there are - * more arguments than required by the {@code format} string, - * then the additional arguments are ignored. + * more arguments than required by {@code format}, + * additional arguments are ignored. * @return this stream. * @throws IllegalFormatException * if the format string is illegal or incompatible with the * arguments, if there are not enough arguments or if any other * error regarding the format string or arguments is detected. - * @throws NullPointerException - * if {@code format} is {@code null}. + * @throws NullPointerException if {@code format == null} */ public PrintStream printf(String format, Object... args) { return format(format, args); @@ -367,19 +362,17 @@ public class PrintStream extends FilterOutputStream implements Appendable, * @param l * the locale used in the method. No localization will be applied * if {@code l} is {@code null}. - * @param format - * the format string used for {@link java.util.Formatter#format}. + * @param format the format string (see {@link java.util.Formatter#format}) * @param args * the list of arguments passed to the formatter. If there are - * more arguments than required by the {@code format} string, - * then the additional arguments are ignored. + * more arguments than required by {@code format}, + * additional arguments are ignored. * @return this stream. * @throws IllegalFormatException * if the format string is illegal or incompatible with the * arguments, if there are not enough arguments or if any other * error regarding the format string or arguments is detected. - * @throws NullPointerException - * if {@code format} is {@code null}. + * @throws NullPointerException if {@code format == null}. */ public PrintStream printf(Locale l, String format, Object... args) { return format(l, format, args); diff --git a/luni/src/main/java/java/io/PrintWriter.java b/luni/src/main/java/java/io/PrintWriter.java index 9f5f3cd..650c61d 100644 --- a/luni/src/main/java/java/io/PrintWriter.java +++ b/luni/src/main/java/java/io/PrintWriter.java @@ -310,19 +310,17 @@ public class PrintWriter extends Writer { * @param l * the locale used in the method. No localization will be applied * if {@code l} is {@code null}. - * @param format - * the format string used for {@link java.util.Formatter#format}. + * @param format the format string (see {@link java.util.Formatter#format}) * @param args * the list of arguments passed to the formatter. If there are - * more arguments than required by the {@code format} string, - * then the additional arguments are ignored. + * more arguments than required by {@code format}, + * additional arguments are ignored. * @return this writer. * @throws IllegalFormatException * if the format string is illegal or incompatible with the * arguments, if there are not enough arguments or if any other * error regarding the format string or arguments is detected. - * @throws NullPointerException - * if {@code format} is {@code null}. + * @throws NullPointerException if {@code format == null} */ public PrintWriter format(Locale l, String format, Object... args) { if (format == null) { @@ -340,19 +338,17 @@ public class PrintWriter extends Writer { * this writer's {@code #format(String, Object...)} method. For the locale, * the default value of the current virtual machine instance is used. * - * @param format - * the format string used for {@link java.util.Formatter#format}. + * @param format the format string (see {@link java.util.Formatter#format}) * @param args * the list of arguments passed to the formatter. If there are - * more arguments than required by the {@code format} string, - * then the additional arguments are ignored. + * more arguments than required by {@code format}, + * additional arguments are ignored. * @return this writer. * @throws IllegalFormatException * if the format string is illegal or incompatible with the * arguments, if there are not enough arguments or if any other * error regarding the format string or arguments is detected. - * @throws NullPointerException - * if {@code format} is {@code null}. + * @throws NullPointerException if {@code format == null} */ public PrintWriter printf(String format, Object... args) { return format(format, args); @@ -365,19 +361,17 @@ public class PrintWriter extends Writer { * @param l * the locale used in the method. No localization will be applied * if {@code l} is {@code null}. - * @param format - * the format string used for {@link java.util.Formatter#format}. + * @param format the format string (see {@link java.util.Formatter#format}) * @param args * the list of arguments passed to the formatter. If there are - * more arguments than required by the {@code format} string, - * then the additional arguments are ignored. + * more arguments than required by {@code format}, + * additional arguments are ignored. * @return this writer. * @throws IllegalFormatException * if the format string is illegal or incompatible with the * arguments, if there are not enough arguments or if any other * error regarding the format string or arguments is detected. - * @throws NullPointerException - * if {@code format} is {@code null}. + * @throws NullPointerException if {@code format == null} */ public PrintWriter printf(Locale l, String format, Object... args) { return format(l, format, args); diff --git a/luni/src/main/java/java/util/Formatter.java b/luni/src/main/java/java/util/Formatter.java index 91209d4..064863b 100644 --- a/luni/src/main/java/java/util/Formatter.java +++ b/luni/src/main/java/java/util/Formatter.java @@ -984,10 +984,8 @@ public final class Formatter implements Closeable, Flushable { * if the {@code Formatter} has been closed. */ public Formatter format(String format, Object... args) { - // BEGIN android-changed doFormat(format, args); return this; - // END android-changed } // BEGIN android-added @@ -1022,7 +1020,6 @@ public final class Formatter implements Closeable, Flushable { * if the {@code Formatter} has been closed. */ public Formatter format(Locale l, String format, Object... args) { - // BEGIN android-changed Locale originalLocale = locale; try { this.locale = l; @@ -1031,7 +1028,6 @@ public final class Formatter implements Closeable, Flushable { this.locale = originalLocale; } return this; - // END android-changed } // BEGIN android-changed diff --git a/text/src/main/java/java/text/MessageFormat.java b/text/src/main/java/java/text/MessageFormat.java index 1f3d24f..6c0a0cd 100644 --- a/text/src/main/java/java/text/MessageFormat.java +++ b/text/src/main/java/java/text/MessageFormat.java @@ -733,25 +733,24 @@ public class MessageFormat extends Format { /** * Formats the supplied objects using the specified message format pattern. * - * @param template - * the pattern to use for formatting. - * @param objects - * the array of objects to format. + * @param format the format string (see {@link java.util.Formatter#format}) + * @param args + * the list of arguments passed to the formatter. If there are + * more arguments than required by {@code format}, + * additional arguments are ignored. * @return the formatted result. * @throws IllegalArgumentException * if the pattern cannot be parsed. */ - public static String format(String template, Object... objects) { - if (objects != null) { - for (int i = 0; i < objects.length; i++) { - if (objects[i] == null) { - objects[i] = "null"; + public static String format(String format, Object... args) { + if (args != null) { + for (int i = 0; i < args.length; i++) { + if (args[i] == null) { + args[i] = "null"; } } } - // BEGIN android-changed - return new MessageFormat(template).format(objects); - // END android-changed + return new MessageFormat(format).format(args); } /** |