aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTania Bento <tbento@redhat.com>2007-04-05 00:15:16 +0000
committerTom Tromey <tromey@gcc.gnu.org>2007-04-05 00:15:16 +0000
commit618bf37b0547c0e994af34ea1e128af320410736 (patch)
treeb659460d69becef2f5b04af277ac9f35a6b13f7f
parentdabf62003ec4a2d31f5b276650b1554db840601a (diff)
downloadgcc-618bf37b0547c0e994af34ea1e128af320410736.zip
gcc-618bf37b0547c0e994af34ea1e128af320410736.tar.gz
gcc-618bf37b0547c0e994af34ea1e128af320410736.tar.bz2
DecimalFormatSymbols.java: Added the year 2007 to Copyright information and introduced new variable, currency.
2007-04-04 Tania Bento <tbento@redhat.com> * java/text/DecimalFormatSymbols.java: Added the year 2007 to Copyright information and introduced new variable, currency. (DecimalFormatSymbols(Locale)): Define currency and intlCurrencySymbol to "XXX", currencySymbol to "?" and localCurrency appropriately. (getCurrency): Fixed documentation and return the value of currency. (setCurrency): Fixed documentation and update the value of currency. (setInternationalCurrencySymbol): Fixed documentation and update the value of currency. * java/util/Currency.java: Introduced two new variables, properties and fractionDigits. In the static block, a properties object is created and the currency resource is loaded. (Currency(Locale)): fractionDigits is defined. (Currency(String)): New method. (getDefaultFractionDigits): Return the value of fractionDigits. (getInstance(String)): Check if String is equal to "XXX". From-SVN: r123512
-rw-r--r--libjava/ChangeLog18
-rw-r--r--libjava/classpath/lib/java/text/DecimalFormatSymbols.classbin6530 -> 6861 bytes
-rw-r--r--libjava/classpath/lib/java/util/Currency.classbin3337 -> 4292 bytes
-rw-r--r--libjava/gnu/java/net/PlainSocketImpl.h2
-rw-r--r--libjava/gnu/java/util/jar/JarUtils.h1
-rw-r--r--libjava/java/lang/VMCompiler.h1
-rw-r--r--libjava/java/text/DecimalFormatSymbols.h1
-rw-r--r--libjava/java/text/DecimalFormatSymbols.java84
-rw-r--r--libjava/java/util/Currency.h3
-rw-r--r--libjava/java/util/Currency.java73
10 files changed, 162 insertions, 21 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog
index 3d0b9ec..ec79a05 100644
--- a/libjava/ChangeLog
+++ b/libjava/ChangeLog
@@ -1,3 +1,21 @@
+2007-04-04 Tania Bento <tbento@redhat.com>
+
+ * java/text/DecimalFormatSymbols.java: Added the year 2007 to
+ Copyright information and introduced new variable, currency.
+ (DecimalFormatSymbols(Locale)): Define currency and intlCurrencySymbol
+ to "XXX", currencySymbol to "?" and localCurrency appropriately.
+ (getCurrency): Fixed documentation and return the value of currency.
+ (setCurrency): Fixed documentation and update the value of currency.
+ (setInternationalCurrencySymbol): Fixed documentation and update the
+ value of currency.
+ * java/util/Currency.java: Introduced two new variables, properties
+ and fractionDigits. In the static block, a properties object is
+ created and the currency resource is loaded.
+ (Currency(Locale)): fractionDigits is defined.
+ (Currency(String)): New method.
+ (getDefaultFractionDigits): Return the value of fractionDigits.
+ (getInstance(String)): Check if String is equal to "XXX".
+
2007-04-04 Kyle Galloway <kgallowa@redhat.com>
* classpath/gnu/classpath/jdwp/util/VariableTable.java: Change longs
diff --git a/libjava/classpath/lib/java/text/DecimalFormatSymbols.class b/libjava/classpath/lib/java/text/DecimalFormatSymbols.class
index a88226f..253b14e 100644
--- a/libjava/classpath/lib/java/text/DecimalFormatSymbols.class
+++ b/libjava/classpath/lib/java/text/DecimalFormatSymbols.class
Binary files differ
diff --git a/libjava/classpath/lib/java/util/Currency.class b/libjava/classpath/lib/java/util/Currency.class
index 147415c..b2ca131 100644
--- a/libjava/classpath/lib/java/util/Currency.class
+++ b/libjava/classpath/lib/java/util/Currency.class
Binary files differ
diff --git a/libjava/gnu/java/net/PlainSocketImpl.h b/libjava/gnu/java/net/PlainSocketImpl.h
index 7872ac2..d907871 100644
--- a/libjava/gnu/java/net/PlainSocketImpl.h
+++ b/libjava/gnu/java/net/PlainSocketImpl.h
@@ -46,8 +46,8 @@ public:
::java::lang::Object * getOption(jint);
void shutdownInput();
void shutdownOutput();
-public: // actually protected
void create(jboolean);
+public: // actually protected
void connect(::java::lang::String *, jint);
void connect(::java::net::InetAddress *, jint);
void connect(::java::net::SocketAddress *, jint);
diff --git a/libjava/gnu/java/util/jar/JarUtils.h b/libjava/gnu/java/util/jar/JarUtils.h
index 4704582..1d12845 100644
--- a/libjava/gnu/java/util/jar/JarUtils.h
+++ b/libjava/gnu/java/util/jar/JarUtils.h
@@ -50,7 +50,6 @@ private:
static void writeVersionInfo(::java::util::jar::Attributes *, ::java::io::OutputStream *);
static void writeAttributeEntry(::java::util::Map$Entry *, ::java::io::OutputStream *);
static void writeHeader(::java::lang::String *, ::java::lang::String *, ::java::io::OutputStream *);
- static ::java::util::logging::Logger * log;
public:
static ::java::lang::String * META_INF;
static ::java::lang::String * DSA_SUFFIX;
diff --git a/libjava/java/lang/VMCompiler.h b/libjava/java/lang/VMCompiler.h
index 9034bd3..e81f694 100644
--- a/libjava/java/lang/VMCompiler.h
+++ b/libjava/java/lang/VMCompiler.h
@@ -41,7 +41,6 @@ public:
private:
VMCompiler();
static ::java::lang::Class * loadSharedLibrary(::java::lang::ClassLoader *, ::java::lang::String *, ::java::security::ProtectionDomain *, ::java::lang::String *);
- static ::java::lang::String * bytesToString(JArray< jbyte > *);
public:
static ::java::lang::Class * compileClass(::java::lang::ClassLoader *, ::java::lang::String *, JArray< jbyte > *, jint, jint, ::java::security::ProtectionDomain *);
static jboolean compileClass(::java::lang::Class *);
diff --git a/libjava/java/text/DecimalFormatSymbols.h b/libjava/java/text/DecimalFormatSymbols.h
index 96bd286..b38140c 100644
--- a/libjava/java/text/DecimalFormatSymbols.h
+++ b/libjava/java/text/DecimalFormatSymbols.h
@@ -83,6 +83,7 @@ private:
jint serialVersionOnStream;
jchar zeroDigit;
::java::util::Locale * locale;
+ ::java::util::Currency * currency;
static const jlong serialVersionUID = 5772796243397350300LL;
public:
static ::java::lang::Class class$;
diff --git a/libjava/java/text/DecimalFormatSymbols.java b/libjava/java/text/DecimalFormatSymbols.java
index c58530f..110e45f 100644
--- a/libjava/java/text/DecimalFormatSymbols.java
+++ b/libjava/java/text/DecimalFormatSymbols.java
@@ -1,5 +1,5 @@
/* DecimalFormatSymbols.java -- Format symbols used by DecimalFormat
- Copyright (C) 1999, 2000, 2001, 2004 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2000, 2001, 2004, 2007 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -121,8 +121,19 @@ public final class DecimalFormatSymbols implements Cloneable, Serializable
/**
* This method initializes a new instance of
* <code>DecimalFormatSymbols</code> for the specified locale.
+ * <strong>Note</strong>: if the locale does not have an associated
+ * <code>Currency</code> instance, the currency symbol and
+ * international currency symbol will be set to the strings "?"
+ * and "XXX" respectively. This generally happens with language
+ * locales (those with no specified country), such as
+ * <code>Locale.ENGLISH</code>. This constructor only obtains
+ * instances using the runtime's resources; to also include
+ * {@link java.text.spi.DecimalFormatSymbolsProvider} instances,
+ * call {@link #getInstance(java.util.Locale)} instead.
*
* @param loc The local to load symbols for.
+ * @throws NullPointerException if the locale is null.
+ * @see #getInstance(java.util.Locale)
*/
public DecimalFormatSymbols (Locale loc)
{
@@ -136,14 +147,26 @@ public final class DecimalFormatSymbols implements Cloneable, Serializable
{
res = null;
}
- currencySymbol = safeGetString (res, "currencySymbol", "$");
+ currency = Currency.getInstance("XXX");
+ currencySymbol = "?";
+ intlCurrencySymbol = "XXX";
+ try
+ {
+ Currency localeCurrency = Currency.getInstance(loc);
+ if (localeCurrency != null)
+ {
+ setCurrency(localeCurrency);
+ }
+ }
+ catch(IllegalArgumentException exception)
+ {
+ /* Locale has an invalid currency */
+ }
decimalSeparator = safeGetChar (res, "decimalSeparator", '.');
digit = safeGetChar (res, "digit", '#');
exponential = safeGetChar (res, "exponential", 'E');
groupingSeparator = safeGetChar (res, "groupingSeparator", ',');
infinity = safeGetString (res, "infinity", "\u221e");
- // FIXME: default?
- intlCurrencySymbol = safeGetString (res, "intlCurrencySymbol", "$");
try
{
monetarySeparator = safeGetChar (res, "monetarySeparator", '.');
@@ -200,12 +223,13 @@ public final class DecimalFormatSymbols implements Cloneable, Serializable
* Returns the currency corresponding to the currency symbol stored
* in the instance of <code>DecimalFormatSymbols</code>.
*
- * @return A new instance of <code>Currency</code> if
- * the currency code matches a known one.
+ * @return An instance of <code>Currency</code> which matches
+ * the currency used, or null if there is no corresponding
+ * instance.
*/
public Currency getCurrency ()
{
- return Currency.getInstance (currencySymbol);
+ return currency;
}
/**
@@ -368,13 +392,16 @@ public final class DecimalFormatSymbols implements Cloneable, Serializable
}
/**
- * This method sets the currency to the specified value.
+ * This method sets the currency symbol and ISO 4217 currency
+ * code to the values obtained from the supplied currency.
*
- * @param currency The new currency
+ * @param currency the currency from which to obtain the values.
+ * @throws NullPointerException if the currency is null.
*/
public void setCurrency (Currency currency)
{
setCurrencySymbol (currency.getSymbol());
+ this.currency = currency;
}
/**
@@ -435,14 +462,31 @@ public final class DecimalFormatSymbols implements Cloneable, Serializable
}
/**
- * This method sets the international currency symbols to the
- * specified value.
+ * This method sets the international currency symbol to the
+ * specified value. If a valid <code>Currency</code> 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 intlCurrencySymbol The new international currency symbol.
+ * @param currencyCode The new international currency symbol.
*/
- public void setInternationalCurrencySymbol (String currency)
+ public void setInternationalCurrencySymbol (String currencyCode)
{
- intlCurrencySymbol = currency;
+ intlCurrencySymbol = currencyCode;
+ try
+ {
+ currency = Currency.getInstance(currencyCode);
+ }
+ catch (IllegalArgumentException exception)
+ {
+ currency = null;
+ }
+ if (currency != null)
+ {
+ setCurrencySymbol(currency.getSymbol(locale));
+ }
}
/**
@@ -593,7 +637,17 @@ public final class DecimalFormatSymbols implements Cloneable, Serializable
* @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)
diff --git a/libjava/java/util/Currency.h b/libjava/java/util/Currency.h
index c868cef..ac8878c 100644
--- a/libjava/java/util/Currency.h
+++ b/libjava/java/util/Currency.h
@@ -13,6 +13,7 @@ class java::util::Currency : public ::java::lang::Object
Currency();
Currency(::java::util::Locale *);
+ Currency(::java::lang::String *);
public:
::java::lang::String * getCurrencyCode();
jint getDefaultFractionDigits();
@@ -28,7 +29,9 @@ public: // actually package-private
private:
::java::util::Locale * __attribute__((aligned(__alignof__( ::java::lang::Object)))) locale;
::java::util::ResourceBundle * res;
+ static ::java::util::Properties * properties;
::java::lang::String * currencyCode;
+ jint fractionDigits;
static ::java::util::Map * cache;
public:
static ::java::lang::Class class$;
diff --git a/libjava/java/util/Currency.java b/libjava/java/util/Currency.java
index e1a28e0..66888fa 100644
--- a/libjava/java/util/Currency.java
+++ b/libjava/java/util/Currency.java
@@ -37,6 +37,7 @@ exception statement from your version. */
package java.util;
+import java.io.IOException;
import java.io.ObjectStreamException;
import java.io.Serializable;
import java.text.NumberFormat;
@@ -83,6 +84,16 @@ public final class Currency
private transient ResourceBundle res;
/**
+ * The set of properties which map a currency to
+ * the currency information such as the ISO 4217
+ * currency code and the number of decimal points.
+ *
+ * @see #getCurrencyCode()
+ * @serial ignored.
+ */
+ private static transient Properties properties;
+
+ /**
* The ISO 4217 currency code associated with this
* particular instance.
*
@@ -92,6 +103,15 @@ public final class Currency
private String currencyCode;
/**
+ * The number of fraction digits associated with this
+ * particular instance.
+ *
+ * @see #getDefaultFractionDigits()
+ * @serial the number of fraction digits
+ */
+ private transient int fractionDigits;
+
+ /**
* A cache of <code>Currency</code> instances to
* ensure the singleton nature of this class. The key
* is the locale of the currency.
@@ -108,6 +128,17 @@ public final class Currency
static
{
cache = new HashMap();
+ /* Create the properties object */
+ properties = new Properties();
+ /* Try and load the properties from our iso4217.properties resource */
+ try
+ {
+ properties.load(Currency.class.getResourceAsStream("iso4217.properties"));
+ }
+ catch (IOException exception)
+ {
+ System.out.println("Failed to load currency resource: " + exception);
+ }
}
/**
@@ -130,9 +161,24 @@ public final class Currency
*/
private Currency (Locale loc)
{
+ String countryCode;
+ String fractionDigitsKey;
+
+ /* Retrieve the country code from the locale */
+ countryCode = loc.getCountry();
+
+ /* If there is no country code, return */
+ if (countryCode.equals(""))
+ {
+ throw new
+ IllegalArgumentException("Invalid (empty) country code for locale:"
+ + loc);
+ }
+
this.locale = loc;
this.res = ResourceBundle.getBundle ("gnu.java.locale.LocaleInformation",
locale, ClassLoader.getSystemClassLoader());
+
/* Retrieve the ISO4217 currency code */
try
{
@@ -142,6 +188,25 @@ public final class Currency
{
currencyCode = null;
}
+
+ /* Construct the key for the fraction digits */
+ fractionDigitsKey = countryCode + ".fractionDigits";
+
+ /* Retrieve the fraction digits */
+ 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 */
}
/**
@@ -168,9 +233,7 @@ public final class Currency
*/
public int getDefaultFractionDigits ()
{
- NumberFormat currency = NumberFormat.getCurrencyInstance (locale);
-
- return currency.getMaximumFractionDigits();
+ return fractionDigits;
}
/**
@@ -226,6 +289,10 @@ public final class Currency
{
Locale[] allLocales = Locale.getAvailableLocales ();
+ /* Nasty special case to allow an erroneous currency... blame Sun */
+ if (currencyCode.equals("XXX"))
+ return new Currency("XXX");
+
for (int i = 0;i < allLocales.length; i++)
{
Currency testCurrency = getInstance (allLocales[i]);