Index: java/text/DecimalFormatSymbols.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/text/DecimalFormatSymbols.java,v
retrieving revision 1.14
diff -u -3 -p -u -r1.14 DecimalFormatSymbols.java
--- java/text/DecimalFormatSymbols.java 30 Dec 2004 12:41:12 -0000 1.14
+++ java/text/DecimalFormatSymbols.java 30 Dec 2004 14:59:37 -0000
@@ -208,14 +208,15 @@ public final class DecimalFormatSymbols
/**
* Returns the currency corresponding to the currency symbol stored
- * in the instance of DecimalFormatSymbols
.
+ * in this instance of DecimalFormatSymbols
.
*
- * @return A new instance of Currency
if
- * the currency code matches a known one.
+ * @return An instance of Currency
which matches
+ * the currency used, or null if there is no corresponding
+ * instance.
*/
public Currency getCurrency ()
{
- return Currency.getInstance(currencySymbol);
+ return currency;
}
/**
@@ -251,7 +252,13 @@ public final class DecimalFormatSymbols
return digit;
}
- // This is our own extension.
+ /**
+ * This method returns the character used to represent the exponential
+ * format. This is a GNU Classpath extension.
+ *
+ * @return the character used to represent an exponential in a format
+ * pattern string.
+ */
char getExponential ()
{
return exponential;
@@ -280,10 +287,10 @@ public final class DecimalFormatSymbols
}
/**
- * This method returns the currency symbol in international format. For
- * example, "C$" for Canadian dollars.
+ * This method returns the ISO 4217 currency code for
+ * the currency used.
*
- * @return The currency symbol in international format.
+ * @return the ISO 4217 currency code.
*/
public String getInternationalCurrencySymbol ()
{
@@ -386,6 +393,7 @@ public final class DecimalFormatSymbols
*/
public void setCurrency (Currency currency)
{
+ this.currency = currency;
intlCurrencySymbol = currency.getCurrencyCode();
currencySymbol = currency.getSymbol();
}
@@ -421,7 +429,12 @@ public final class DecimalFormatSymbols
this.digit = digit;
}
- // This is our own extension.
+ /**
+ * This method sets the exponential character used in the format string to
+ * the specified value. This is a GNU Classpath extension.
+ *
+ * @param exp the character used for the exponential in a format pattern.
+ */
void setExponential (char exp)
{
exponential = exp;
@@ -449,25 +462,26 @@ public final class DecimalFormatSymbols
/**
* This method sets the international currency symbol to the
- * specified value. The currency symbol is also modified if a
- * valid symbol exists for the supplied currency in the locale
- * used by this instance.
+ * specified value. If a valid Currency
instance
+ * exists for the international currency code, then this is
+ * used for the currency attribute, and the currency symbol
+ * is set to the corresponding value from this instance.
+ * Otherwise, the currency attribute is set to null and the
+ * symbol is left unmodified.
*
* @param currencyCode The new international currency symbol.
*/
public void setInternationalCurrencySymbol (String currencyCode)
{
- Currency currency;
-
intlCurrencySymbol = currencyCode;
- try
- {
- currency = Currency.getInstance(currencyCode);
- }
- catch (IllegalArgumentException exception)
- {
- currency = null;
- }
+ try
+ {
+ currency = Currency.getInstance(currencyCode);
+ }
+ catch (IllegalArgumentException exception)
+ {
+ currency = null;
+ }
if (currency != null)
{
setCurrencySymbol(currency.getSymbol(locale));
@@ -623,7 +637,17 @@ public final class DecimalFormatSymbols
* @serial The locale of these currency symbols.
*/
private Locale locale;
-
+
+ /**
+ * The currency used for the symbols in this instance.
+ * This is stored temporarily for efficiency reasons,
+ * as well as to ensure that the correct instance
+ * is restored from the currency code.
+ *
+ * @serial Ignored.
+ */
+ private transient Currency currency;
+
private static final long serialVersionUID = 5772796243397350300L;
private void readObject(ObjectInputStream stream)
Index: java/text/NumberFormat.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/text/NumberFormat.java,v
retrieving revision 1.15
diff -u -3 -p -u -r1.15 NumberFormat.java
--- java/text/NumberFormat.java 30 Dec 2004 12:41:12 -0000 1.15
+++ java/text/NumberFormat.java 30 Dec 2004 14:59:37 -0000
@@ -347,7 +347,11 @@ public abstract class NumberFormat exten
*/
public static NumberFormat getCurrencyInstance (Locale loc)
{
- return computeInstance (loc, "currencyFormat", "$#,##0.00;($#,##0.00)");
+ NumberFormat format;
+
+ format = computeInstance (loc, "currencyFormat", "$#,##0.00;($#,##0.00)");
+ format.setMaximumFractionDigits(format.getCurrency().getDefaultFractionDigits());
+ return format;
}
/**