summaryrefslogtreecommitdiffstats
path: root/libjava/java/text/MessageFormat.java
diff options
context:
space:
mode:
authortromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>2001-02-07 22:46:28 +0000
committertromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>2001-02-07 22:46:28 +0000
commit810295ed9bb77d96e4fc59479d7e7e4d390a6212 (patch)
tree701f9dfe64155ce6a6ecba35972722b5486402b1 /libjava/java/text/MessageFormat.java
parent301dfdef9f52bf834f0df7aa4088446819298e60 (diff)
downloadppe42-gcc-810295ed9bb77d96e4fc59479d7e7e4d390a6212.tar.gz
ppe42-gcc-810295ed9bb77d96e4fc59479d7e7e4d390a6212.zip
Fix for PR libgcj/1906:
* java/text/MessageFormat.java (setLocale): Use named class literals. (forName): Removed. (format(Object,StringBuffer,FieldPosition)): Special case if argument is an Object[]. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@39529 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/java/text/MessageFormat.java')
-rw-r--r--libjava/java/text/MessageFormat.java42
1 files changed, 17 insertions, 25 deletions
diff --git a/libjava/java/text/MessageFormat.java b/libjava/java/text/MessageFormat.java
index 7109fcf7d04..2cd6386a00c 100644
--- a/libjava/java/text/MessageFormat.java
+++ b/libjava/java/text/MessageFormat.java
@@ -1,6 +1,6 @@
// MessageFormat.java - Localized message formatting.
-/* Copyright (C) 1999 Free Software Foundation
+/* Copyright (C) 1999, 2001 Free Software Foundation
This file is part of libgcj.
@@ -45,19 +45,6 @@ final class MessageFormatElement
// Text to follow this element.
String trailer;
- // FIXME: shouldn't need this.
- Class forName (String name)
- {
- try
- {
- return Class.forName (name);
- }
- catch (ClassNotFoundException x)
- {
- }
- return null;
- }
-
// Recompute the locale-based formatter.
void setLocale (Locale loc)
{
@@ -65,9 +52,7 @@ final class MessageFormatElement
;
else if (type.equals("number"))
{
- // FIXME: named class literal.
- // formatClass = Number.class;
- formatClass = forName ("java.lang.Number");
+ formatClass = java.lang.Number.class;
if (style == null)
format = NumberFormat.getInstance(loc);
@@ -98,9 +83,7 @@ final class MessageFormatElement
}
else if (type.equals("time") || type.equals("date"))
{
- // FIXME: named class literal.
- // formatClass = Date.class;
- formatClass = forName ("java.util.Date");
+ formatClass = java.util.Date.class;
int val = DateFormat.DEFAULT;
if (style == null)
@@ -127,9 +110,7 @@ final class MessageFormatElement
}
else if (type.equals("choice"))
{
- // FIXME: named class literal.
- // formatClass = Number.class;
- formatClass = forName ("java.lang.Number");
+ formatClass = java.lang.Number.class;
if (style == null)
throw new
@@ -370,8 +351,19 @@ public class MessageFormat extends Format
public final StringBuffer format (Object singleArg, StringBuffer appendBuf,
FieldPosition ignore)
{
- Object[] args = new Object[1];
- args[0] = singleArg;
+ Object[] args;
+
+ if (singleArg instanceof Object[])
+ {
+ // This isn't specified in any manual, but it follows the
+ // JDK implementation.
+ args = (Object[]) singleArg;
+ }
+ else
+ {
+ args = new Object[1];
+ args[0] = singleArg;
+ }
return format (args, appendBuf, ignore);
}
OpenPOWER on IntegriCloud