From fac6a094be0f8e14dcc947d1eb81abcea19d9c92 Mon Sep 17 00:00:00 2001 From: Andrew John Hughes Date: Sat, 16 Apr 2005 01:22:52 +0000 Subject: 2005-04-15 Andrew John Hughes * java/text/DecimalFormatSymbols.java: Added retrieval of "XXX" instance in place of null. * java/util/Currency.java, (Currency(String)): New constructor for the XXX special case. (getInstance(String)): Allow special case of "XXX". --- java/text/DecimalFormatSymbols.java | 2 +- java/util/Currency.java | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) (limited to 'java') diff --git a/java/text/DecimalFormatSymbols.java b/java/text/DecimalFormatSymbols.java index b596233d4..01ead2412 100644 --- a/java/text/DecimalFormatSymbols.java +++ b/java/text/DecimalFormatSymbols.java @@ -146,7 +146,7 @@ public final class DecimalFormatSymbols implements Cloneable, Serializable { ResourceBundle res; - currency = null; + currency = Currency.getInstance("XXX"); currencySymbol = "?"; intlCurrencySymbol = "XXX"; try diff --git a/java/util/Currency.java b/java/util/Currency.java index 1a364f0c4..ec8fe3d52 100644 --- a/java/util/Currency.java +++ b/java/util/Currency.java @@ -198,6 +198,19 @@ public final class Currency fractionDigits = Integer.parseInt(properties.getProperty(fractionDigitsKey)); } + /** + * Constructor for the "XXX" special case. This allows + * a Currency to be constructed from an assumed good + * currency code. + * + * @param code the code to use. + */ + private Currency(String code) + { + currencyCode = code; + fractionDigits = -1; /* Pseudo currency */ + } + /** * Returns the ISO4217 currency code of this currency. * @@ -303,12 +316,16 @@ public final class Currency /* * Throw a null pointer exception explicitly if currencyCode is null. - * One is not thrown otherwise. It results in an IllegalArgumentException. + * One is not thrown otherwise. It results in an + * IllegalArgumentException. */ if (currencyCode == null) { throw new NullPointerException("The supplied currency code is null."); } + /* Nasty special case to allow an erroneous currency... blame Sun */ + if (currencyCode.equals("XXX")) + return new Currency("XXX"); Currency newCurrency = (Currency) cache.get(currencyCode); if (newCurrency == null) { -- cgit v1.2.1