[kaffe] CVS kaffe (kaz): libraries/javalib/java/text/MessageFormat.java
Kaffe CVS
cvs-commits at kaffe.org
Tue Jun 15 08:25:04 PDT 2004
PatchSet 4844
Date: 2004/06/15 14:49:17
Author: kaz
Branch: HEAD
Tag: (none)
Log:
2004-06-15 Ito Kazumitsu <kaz at maczuka.gcd.org>
* libraries/javalib/java/text/MessageFormat.java
(formatInternal) Append "{n}" if argument n is unavailable.
Members:
ChangeLog:1.2411->1.2412
libraries/javalib/java/text/MessageFormat.java:1.25->1.26
Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.2411 kaffe/ChangeLog:1.2412
--- kaffe/ChangeLog:1.2411 Mon Jun 14 17:44:00 2004
+++ kaffe/ChangeLog Tue Jun 15 14:49:17 2004
@@ -1,3 +1,8 @@
+2004-06-15 Ito Kazumitsu <kaz at maczuka.gcd.org>
+
+ * libraries/javalib/java/text/MessageFormat.java
+ (formatInternal) Append "{n}" if argument n is unavailable.
+
2004-06-14 Guilhem Lavaux <guilhem at kaffe.org>
* kaffe/kaffevm/systems/unix-jthreads/signal.c
Index: kaffe/libraries/javalib/java/text/MessageFormat.java
diff -u kaffe/libraries/javalib/java/text/MessageFormat.java:1.25 kaffe/libraries/javalib/java/text/MessageFormat.java:1.26
--- kaffe/libraries/javalib/java/text/MessageFormat.java:1.25 Mon Mar 22 11:25:05 2004
+++ kaffe/libraries/javalib/java/text/MessageFormat.java Tue Jun 15 14:49:21 2004
@@ -157,7 +157,7 @@
* This is the attribute set for all characters produced
* by MessageFormat during a formatting.
*/
- public static final MessageFormat.Field ARGUMENT = new Field("argument");
+ public static final MessageFormat.Field ARGUMENT = new MessageFormat.Field("argument");
// For deserialization
private Field()
@@ -414,10 +414,12 @@
for (int i = 0; i < elements.length; ++i)
{
+ Object thisArg = null;
+ boolean unavailable = false;
if (elements[i].argNumber >= arguments.length)
- throw new IllegalArgumentException("Not enough arguments given");
-
- Object thisArg = arguments[elements[i].argNumber];
+ unavailable = true;
+ else
+ thisArg = arguments[elements[i].argNumber];
AttributedCharacterIterator iterator = null;
Format formatter = null;
@@ -425,22 +427,27 @@
if (fp != null && i == fp.getField() && fp.getFieldAttribute() == Field.ARGUMENT)
fp.setBeginIndex(appendBuf.length());
- if (elements[i].setFormat != null)
- formatter = elements[i].setFormat;
- else if (elements[i].format != null)
+ if (unavailable)
+ appendBuf.append("{" + elements[i].argNumber + "}");
+ else
{
- if (elements[i].formatClass != null
- && ! elements[i].formatClass.isInstance(thisArg))
- throw new IllegalArgumentException("Wrong format class");
+ if (elements[i].setFormat != null)
+ formatter = elements[i].setFormat;
+ else if (elements[i].format != null)
+ {
+ if (elements[i].formatClass != null
+ && ! elements[i].formatClass.isInstance(thisArg))
+ throw new IllegalArgumentException("Wrong format class");
- formatter = elements[i].format;
+ formatter = elements[i].format;
+ }
+ else if (thisArg instanceof Number)
+ formatter = NumberFormat.getInstance(locale);
+ else if (thisArg instanceof Date)
+ formatter = DateFormat.getTimeInstance(DateFormat.DEFAULT, locale);
+ else
+ appendBuf.append(thisArg);
}
- else if (thisArg instanceof Number)
- formatter = NumberFormat.getInstance(locale);
- else if (thisArg instanceof Date)
- formatter = DateFormat.getTimeInstance(DateFormat.DEFAULT, locale);
- else
- appendBuf.append(thisArg);
if (fp != null && fp.getField() == i && fp.getFieldAttribute() == Field.ARGUMENT)
fp.setEndIndex(appendBuf.length());
More information about the kaffe
mailing list