harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ton...@apache.org
Subject svn commit: r592434 [1/2] - in /harmony/enhanced/classlib/trunk/modules: luni/make/ luni/src/main/java/java/util/ luni/src/main/java/org/apache/harmony/luni/internal/locale/ luni/src/test/api/common/tests/api/java/util/ text/make/ text/src/main/java/ja...
Date Tue, 06 Nov 2007 14:21:11 GMT
Author: tonywu
Date: Tue Nov  6 06:21:10 2007
New Revision: 592434

URL: http://svn.apache.org/viewvc?rev=592434&view=rev
Log:
Apply patch Harmony-5061 which removes the duplicate locale data

Removed:
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/locale/
Modified:
    harmony/enhanced/classlib/trunk/modules/luni/make/exclude.common
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Calendar.java
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Currency.java
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Locale.java
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/TimeZone.java
    harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/tests/api/java/util/DateTest.java
    harmony/enhanced/classlib/trunk/modules/text/make/exclude.common
    harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/DateFormat.java
    harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/DateFormatSymbols.java
    harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/DecimalFormat.java
    harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/DecimalFormatSymbols.java
    harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/Format.java
    harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/NumberFormat.java
    harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/SimpleDateFormat.java
    harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/CollationElementIteratorTest.java
    harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/DateFormatSymbolsTest.java
    harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/DecimalFormatSymbolsTest.java
    harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/RuleBasedCollatorTest.java

Modified: harmony/enhanced/classlib/trunk/modules/luni/make/exclude.common
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/make/exclude.common?rev=592434&r1=592433&r2=592434&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/make/exclude.common (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/make/exclude.common Tue Nov  6 06:21:10 2007
@@ -1,2 +1,7 @@
 tests/api/java/net/URLClassLoaderTest.java
 tests/api/java/net/ExcludedProxyTest.java
+tests/api/java/util/CurrencyTest.java
+tests/api/java/util/FormatterTest.java
+tests/api/java/util/GregorianCalendarTest.java
+tests/api/java/util/LocaleTest.java
+tests/api/java/util/ScannerTest.java

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Calendar.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Calendar.java?rev=592434&r1=592433&r2=592434&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Calendar.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Calendar.java Tue Nov  6 06:21:10 2007
@@ -129,12 +129,13 @@
 	 *            the locale
 	 */
 	protected Calendar(TimeZone timezone, Locale locale) {
-		this(timezone);
-		ResourceBundle bundle = Locale.getBundle("Locale", locale); //$NON-NLS-1$
-		setFirstDayOfWeek(((Integer) bundle.getObject("First_Day")).intValue()); //$NON-NLS-1$
-		setMinimalDaysInFirstWeek(((Integer) bundle.getObject("Minimal_Days")) //$NON-NLS-1$
-				.intValue());
-	}
+        this(timezone);
+        com.ibm.icu.util.Calendar icuCalendar = com.ibm.icu.util.Calendar
+                .getInstance(com.ibm.icu.util.SimpleTimeZone
+                        .getTimeZone(timezone.getID()), locale);
+        setFirstDayOfWeek(icuCalendar.getFirstDayOfWeek());
+        setMinimalDaysInFirstWeek(icuCalendar.getMinimalDaysInFirstWeek());
+    }
 
 	/**
 	 * Adds the specified amount to a Calendar field.

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Currency.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Currency.java?rev=592434&r1=592433&r2=592434&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Currency.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Currency.java Tue Nov  6 06:21:10 2007
@@ -19,8 +19,6 @@
 
 import java.io.Serializable;
 
-import org.apache.harmony.luni.util.Msg;
-
 /**
  * This class represents a currency as identified in the ISO 4217 currency
  * codes.
@@ -33,10 +31,6 @@
 
     private String currencyCode;
 
-    private static String currencyVars = "EURO, HK, PREEURO"; //$NON-NLS-1$
-
-    private transient int defaultFractionDigits;
-
     /**
      * @param currencyCode
      */
@@ -60,20 +54,7 @@
         Currency currency = codesToCurrencies.get(currencyCode);
 
         if (currency == null) {
-            ResourceBundle bundle = Locale.getBundle(
-                    "ISO4CurrenciesToDigits", Locale.getDefault()); //$NON-NLS-1$
             currency = new Currency(currencyCode);
-
-            String defaultFractionDigits = null;
-            try {
-                defaultFractionDigits = bundle.getString(currencyCode);
-            } catch (MissingResourceException e) {
-                throw new IllegalArgumentException(
-                        org.apache.harmony.luni.util.Msg.getString(
-                                "K0322", currencyCode)); //$NON-NLS-1$
-            }
-            currency.defaultFractionDigits = Integer
-                    .parseInt(defaultFractionDigits);
             codesToCurrencies.put(currencyCode, currency);
         }
 
@@ -91,21 +72,11 @@
      *             if the locale's country is not a supported ISO 3166 Country
      */
     public static Currency getInstance(Locale locale) {
-        String country = locale.getCountry();
-        String variant = locale.getVariant();
-        if (!variant.equals("") && currencyVars.indexOf(variant) > -1) { //$NON-NLS-1$
-            country = country + "_" + variant; //$NON-NLS-1$
-        }
-
-        ResourceBundle bundle = Locale.getBundle(
-                "ISO4Currencies", Locale.getDefault()); //$NON-NLS-1$
-        String currencyCode = null;
-        try {
-            currencyCode = bundle.getString(country);
-        } catch (MissingResourceException e) {
-            throw new IllegalArgumentException(Msg.getString(
-                    "K0323", locale.toString())); //$NON-NLS-1$
+        com.ibm.icu.util.Currency currency = com.ibm.icu.util.Currency.getInstance(locale);
+        if(currency == null) {
+            return null;
         }
+        String currencyCode = currency.getCurrencyCode();
 
         if (currencyCode.equals("None")) { //$NON-NLS-1$
             return null;
@@ -161,35 +132,7 @@
         if (locale.getCountry().equals("")) { //$NON-NLS-1$
             return currencyCode;
         }
-
-        // check in the Locale bundle first, if the local has the same currency
-        ResourceBundle bundle = Locale.getBundle("Locale", locale); //$NON-NLS-1$
-        if (((String) bundle.getObject("IntCurrencySymbol")) //$NON-NLS-1$
-                .equals(currencyCode)) {
-            return (String) bundle.getObject("CurrencySymbol"); //$NON-NLS-1$
-        }
-
-        // search for a Currency bundle
-        bundle = null;
-        try {
-            bundle = Locale.getBundle("Currency", locale); //$NON-NLS-1$
-        } catch (MissingResourceException e) {
-            return currencyCode;
-        }
-
-        // is the bundle found for a different country? (for instance the
-        // default locale's currency bundle)
-        if (!bundle.getLocale().getCountry().equals(locale.getCountry())) {
-            return currencyCode;
-        }
-
-        // check if the currency bundle for this locale
-        // has an entry for this currency
-        String result = (String) bundle.handleGetObject(currencyCode);
-        if (result != null) {
-            return result;
-        }
-        return currencyCode;
+        return com.ibm.icu.util.Currency.getInstance(currencyCode).getSymbol(locale);
     }
 
     /**
@@ -200,7 +143,7 @@
      * @return the default number of fraction digits for this currency
      */
     public int getDefaultFractionDigits() {
-        return defaultFractionDigits;
+        return com.ibm.icu.util.Currency.getInstance(currencyCode).getDefaultFractionDigits();
     }
 
     /**

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Locale.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Locale.java?rev=592434&r1=592433&r2=592434&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Locale.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Locale.java Tue Nov  6 06:21:10 2007
@@ -24,14 +24,12 @@
 import java.io.ObjectStreamField;
 import java.io.Serializable;
 import java.security.AccessController;
-import java.security.PrivilegedAction;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipFile;
 
-import org.apache.harmony.luni.internal.locale.Country;
-import org.apache.harmony.luni.internal.locale.Language;
 import org.apache.harmony.luni.util.PriviAction;
-import org.apache.harmony.luni.util.Util;
+
+import com.ibm.icu.util.ULocale;
 
 /**
  * Locale represents a language/country/variant combination. It is an identifier
@@ -46,8 +44,6 @@
 	
 	private static final long serialVersionUID = 9149081749638150636L;
 
-	private static volatile Locale[] availableLocales;
-
 	// Initialize a default which is used during static
 	// initialization of the default for the platform.
 	private static Locale defaultLocale = new Locale();
@@ -174,6 +170,8 @@
     private transient String languageCode;
     private transient String variantCode;
 
+    private transient ULocale uLocale;
+
 	/**
 	 * Constructs a default which is used during static initialization of the
 	 * default for the platform.
@@ -218,7 +216,14 @@
         if (language == null || country == null || variant == null) {
             throw new NullPointerException();
         }
-        languageCode = Util.toASCIILowerCase(language);
+        if(language.length() == 0 && country.length() == 0){
+            languageCode = "";
+            countryCode = "";
+            variantCode = variant;
+            return;
+        }
+        this.uLocale = new ULocale(language, country, variant);
+        languageCode = uLocale.getLanguage();
         // Map new language codes to the obsolete language
         // codes so the correct resource bundles will be used.
         if (languageCode.equals("he")) {//$NON-NLS-1$
@@ -230,9 +235,9 @@
         }
 
         // countryCode is defined in ASCII character set
-        countryCode = Util.toASCIIUpperCase(country);
+        countryCode = uLocale.getCountry();
 
-        variantCode = variant;
+        variantCode = uLocale.getVariant();
     }
 
 	/**
@@ -367,15 +372,12 @@
 	 * @return an array of Locale
 	 */
 	public static Locale[] getAvailableLocales() {
-		if (availableLocales == null) {
-            availableLocales = AccessController
-                    .doPrivileged(new PrivilegedAction<Locale[]>() {
-                        public Locale[] run() {
-                            return find("org/apache/harmony/luni/internal/locale/Locale_"); //$NON-NLS-1$
-                        }
-                    });
+		ULocale[] ulocales =  ULocale.getAvailableLocales();
+        Locale[] locales = new Locale[ulocales.length];
+        for (int i = 0; i < locales.length; i++) {
+            locales[i] = ulocales[i].toLocale();
         }
-		return availableLocales.clone();
+        return locales;
 	}
 
 	/**
@@ -417,24 +419,7 @@
 	 * @return a country name
 	 */
 	public String getDisplayCountry(Locale locale) {
-		if (countryCode.length() == 0) {
-            return countryCode;
-        }
-		try {
-			// First try the specified locale
-			ResourceBundle bundle = getBundle("Country", locale); //$NON-NLS-1$
-			String result = (String) bundle.handleGetObject(countryCode);
-			if (result != null) {
-                return result;
-            }
-			// Now use the default locale
-			if (locale != Locale.getDefault()) {
-                bundle = getBundle("Country", Locale.getDefault()); //$NON-NLS-1$
-            }
-			return bundle.getString(countryCode);
-		} catch (MissingResourceException e) {
-			return countryCode;
-		}
+		return ULocale.forLocale(this).getDisplayCountry(ULocale.forLocale(locale));
 	}
 
 	/**
@@ -458,24 +443,7 @@
 	 * @return a language name
 	 */
 	public String getDisplayLanguage(Locale locale) {
-		if (languageCode.length() == 0) {
-            return languageCode;
-        }
-		try {
-			// First try the specified locale
-			ResourceBundle bundle = getBundle("Language", locale); //$NON-NLS-1$
-			String result = (String) bundle.handleGetObject(languageCode);
-			if (result != null) {
-                return result;
-            }
-			// Now use the default locale
-			if (locale != Locale.getDefault()) {
-                bundle = getBundle("Language", Locale.getDefault()); //$NON-NLS-1$
-            }
-			return bundle.getString(languageCode);
-		} catch (MissingResourceException e) {
-			return languageCode;
-		}
+        return ULocale.forLocale(this).getDisplayLanguage(ULocale.forLocale(locale));
 	}
 
 	/**
@@ -546,31 +514,7 @@
 	 * @return a variant name
 	 */
 	public String getDisplayVariant(Locale locale) {
-		if (variantCode.length() == 0) {
-            return variantCode;
-        }
-		ResourceBundle bundle;
-		try {
-			bundle = getBundle("Variant", locale); //$NON-NLS-1$
-		} catch (MissingResourceException e) {
-			return variantCode.replace('_', ',');
-		}
-
-		StringBuffer result = new StringBuffer();
-		StringTokenizer tokens = new StringTokenizer(variantCode, "_"); //$NON-NLS-1$
-		while (tokens.hasMoreTokens()) {
-			String code, variant = tokens.nextToken();
-			try {
-				code = bundle.getString(variant);
-			} catch (MissingResourceException e) {
-				code = variant;
-			}
-			result.append(code);
-			if (tokens.hasMoreTokens()) {
-                result.append(',');
-            }
-		}
-		return result.toString();
+        return ULocale.forLocale(this).getDisplayVariant(ULocale.forLocale(locale));
 	}
 
 	/**
@@ -583,11 +527,7 @@
 	 *                when there is no matching three letter ISO country code
 	 */
 	public String getISO3Country() throws MissingResourceException {
-		if (countryCode.length() == 0) {
-            return ""; //$NON-NLS-1$
-        }
-		ResourceBundle bundle = getBundle("ISO3Countries", this); //$NON-NLS-1$
-		return bundle.getString(countryCode);
+        return ULocale.forLocale(this).getISO3Country();
 	}
 
 	/**
@@ -600,11 +540,7 @@
 	 *                when there is no matching three letter ISO language code
 	 */
 	public String getISO3Language() throws MissingResourceException {
-		if (languageCode.length() == 0) {
-            return ""; //$NON-NLS-1$
-        }
-		ResourceBundle bundle = getBundle("ISO3Languages", this); //$NON-NLS-1$
-		return bundle.getString(languageCode);
+        return ULocale.forLocale(this).getISO3Language();
 	}
 
 	/**
@@ -614,18 +550,7 @@
 	 * @return an array of String
 	 */
 	public static String[] getISOCountries() {
-        ListResourceBundle bundle = new Country();
-
-        // To initialize the table
-        Enumeration<String> keys = bundle.getKeys(); 
-        int size = bundle.table.size();
-        String[] result = new String[size];
-        int index = 0;
-        while (keys.hasMoreElements()) {
-            String element = keys.nextElement();
-            result[index++] = element;
-        }
-        return result;
+        return ULocale.getISOCountries();
     }
 
 	/**
@@ -635,14 +560,7 @@
 	 * @return an array of String
 	 */
 	public static String[] getISOLanguages() {
-		ListResourceBundle bundle = new Language();
-		Enumeration<String> keys = bundle.getKeys(); // to initialize the table
-		String[] result = new String[bundle.table.size()];
-		int index = 0;
-		while (keys.hasMoreElements()) {
-            result[index++] = keys.nextElement();
-        }
-		return result;
+        return ULocale.getISOLanguages();
 	}
 
 	/**
@@ -721,15 +639,6 @@
 			result.append(variantCode);
 		}
 		return result.toString();
-	}
-
-	static ResourceBundle getBundle(final String clName, final Locale locale) {
-		return AccessController.doPrivileged(new PrivilegedAction<ResourceBundle>() {
-					public ResourceBundle run() {
-						return ResourceBundle.getBundle("org.apache.harmony.luni.internal.locale." //$NON-NLS-1$
-								+ clName, locale);
-					}
-				});
 	}
 
 	private static final ObjectStreamField[] serialPersistentFields = {

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/TimeZone.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/TimeZone.java?rev=592434&r1=592433&r2=592434&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/TimeZone.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/TimeZone.java Tue Nov  6 06:21:10 2007
@@ -20,6 +20,7 @@
 
 import java.io.Serializable;
 import java.security.AccessController;
+import java.security.PrivilegedAction;
 import java.text.DateFormatSymbols;
 
 import org.apache.harmony.luni.util.PriviAction;
@@ -445,8 +446,27 @@
 	 */
 	public static synchronized void setDefault(TimeZone timezone) {
 		if (timezone != null) {
-			Default = timezone;
-			return;
+            final com.ibm.icu.util.TimeZone icuTZ = com.ibm.icu.util.TimeZone
+                    .getTimeZone(timezone.getID());
+
+            AccessController
+                    .doPrivileged(new PrivilegedAction<java.lang.reflect.Field>() {
+                        public java.lang.reflect.Field run() {
+                            java.lang.reflect.Field field = null;
+                            try {
+                                field = com.ibm.icu.util.TimeZone.class
+                                        .getDeclaredField("defaultZone");
+                                field.setAccessible(true);
+                                field.set("defaultZone", icuTZ);
+                            } catch (Exception e) {
+                                return null;
+                            }
+                            return field;
+                        }
+                    });
+            
+            Default = timezone;
+            return;
 		}
 
 		String zone = AccessController.doPrivileged(new PriviAction<String>(

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/tests/api/java/util/DateTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/tests/api/java/util/DateTest.java?rev=592434&r1=592433&r2=592434&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/tests/api/java/util/DateTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/tests/api/java/util/DateTest.java Tue Nov  6 06:21:10 2007
@@ -436,12 +436,13 @@
 		TimeZone tz = TimeZone.getDefault();
 		TimeZone.setDefault(TimeZone.getTimeZone("EST"));
 		try {
-			Date d1 = new Date(0);
-			assertTrue("Returned incorrect string: " + d1, d1.toString()
-					.equals("Wed Dec 31 19:00:00 EST 1969"));
-		} finally {
-			TimeZone.setDefault(tz);
-		}
+            Date d1 = new Date(0);
+            assertTrue("Returned incorrect string: " + d1, d1.toString()
+                    .startsWith("Wed Dec 31 19:00:00")
+                    && d1.toString().endsWith("1969"));
+        } finally {
+            TimeZone.setDefault(tz);
+        }
 	}
 
 	/**

Modified: harmony/enhanced/classlib/trunk/modules/text/make/exclude.common
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/text/make/exclude.common?rev=592434&r1=592433&r2=592434&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/text/make/exclude.common (original)
+++ harmony/enhanced/classlib/trunk/modules/text/make/exclude.common Tue Nov  6 06:21:10 2007
@@ -1,2 +1,5 @@
 org/apache/harmony/text/tests/java/text/DecimalFormatTest.java
 org/apache/harmony/text/tests/java/text/MessageFormatTest.java
+org/apache/harmony/text/tests/java/text/DecimalFormatSymbolsTest.java
+org/apache/harmony/text/tests/java/text/NumberFormatTest.java
+org/apache/harmony/text/tests/java/text/SimpleDateFormatTest.java

Modified: harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/DateFormat.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/DateFormat.java?rev=592434&r1=592433&r2=592434&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/DateFormat.java (original)
+++ harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/DateFormat.java Tue Nov  6 06:21:10 2007
@@ -22,7 +22,6 @@
 import java.util.Date;
 import java.util.Hashtable;
 import java.util.Locale;
-import java.util.ResourceBundle;
 import java.util.TimeZone;
 
 import org.apache.harmony.text.internal.nls.Messages;
@@ -321,9 +320,8 @@
      */
     public final static DateFormat getDateInstance(int style, Locale locale) {
         checkDateStyle(style);
-        ResourceBundle bundle = getBundle(locale);
-        String pattern = bundle.getString("Date_" + getStyleName(style)); //$NON-NLS-1$
-        return new SimpleDateFormat(pattern, locale);
+        com.ibm.icu.text.DateFormat icuFormat = com.ibm.icu.text.DateFormat.getDateInstance(style, locale);
+        return new SimpleDateFormat(locale, (com.ibm.icu.text.SimpleDateFormat)icuFormat);
     }
 
     /**
@@ -370,10 +368,8 @@
             int timeStyle, Locale locale) {
         checkTimeStyle(timeStyle);
         checkDateStyle(dateStyle);
-        ResourceBundle bundle = getBundle(locale);
-        String pattern = bundle.getString("Date_" + getStyleName(dateStyle)) //$NON-NLS-1$
-                + " " + bundle.getString("Time_" + getStyleName(timeStyle)); //$NON-NLS-1$ //$NON-NLS-2$
-        return new SimpleDateFormat(pattern, locale);
+        com.ibm.icu.text.DateFormat icuFormat = com.ibm.icu.text.DateFormat.getDateTimeInstance(dateStyle, timeStyle, locale);
+        return new SimpleDateFormat(locale, (com.ibm.icu.text.SimpleDateFormat)icuFormat);
     }
 
     /**
@@ -451,9 +447,8 @@
      */
     public final static DateFormat getTimeInstance(int style, Locale locale) {
         checkTimeStyle(style);
-        ResourceBundle bundle = getBundle(locale);
-        String pattern = bundle.getString("Time_" + getStyleName(style)); //$NON-NLS-1$
-        return new SimpleDateFormat(pattern, locale);
+        com.ibm.icu.text.DateFormat icuFormat = com.ibm.icu.text.DateFormat.getTimeInstance(style, locale);
+        return new SimpleDateFormat(locale, (com.ibm.icu.text.SimpleDateFormat)icuFormat);
     }
 
     /**

Modified: harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/DateFormatSymbols.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/DateFormatSymbols.java?rev=592434&r1=592433&r2=592434&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/DateFormatSymbols.java (original)
+++ harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/DateFormatSymbols.java Tue Nov  6 06:21:10 2007
@@ -20,7 +20,6 @@
 import java.io.Serializable;
 import java.util.Arrays;
 import java.util.Locale;
-import java.util.ResourceBundle;
 
 /**
  * DateFormatSymbols holds the Strings used in the formating and parsing of
@@ -52,15 +51,16 @@
      *            the Locale
      */
     public DateFormatSymbols(Locale locale) {
-        ResourceBundle bundle = Format.getBundle(locale);
-        localPatternChars = bundle.getString("LocalPatternChars"); //$NON-NLS-1$
-        ampms = bundle.getStringArray("ampm"); //$NON-NLS-1$
-        eras = bundle.getStringArray("eras"); //$NON-NLS-1$
-        months = bundle.getStringArray("months"); //$NON-NLS-1$
-        shortMonths = bundle.getStringArray("shortMonths"); //$NON-NLS-1$
-        shortWeekdays = bundle.getStringArray("shortWeekdays"); //$NON-NLS-1$
-        weekdays = bundle.getStringArray("weekdays"); //$NON-NLS-1$
-        zoneStrings = (String[][]) bundle.getObject("timezones"); //$NON-NLS-1$
+        com.ibm.icu.text.DateFormatSymbols icuSymbols = new com.ibm.icu.text.DateFormatSymbols(locale);
+        
+        localPatternChars = icuSymbols.getLocalPatternChars();
+        ampms = icuSymbols.getAmPmStrings();
+        eras = icuSymbols.getEras();
+        months = icuSymbols.getMonths();
+        shortMonths = icuSymbols.getShortMonths();
+        shortWeekdays = icuSymbols.getShortWeekdays();
+        weekdays = icuSymbols.getWeekdays();
+        zoneStrings = icuSymbols.getZoneStrings();
     }
 
     /**
@@ -273,7 +273,9 @@
         }
         for (String[] element : zoneStrings) {
             for (int j = 0; j < element.length; j++) {
-                hashCode += element[j].hashCode();
+                if (element[j] != null) {
+                    hashCode += element[j].hashCode();
+                }
             }
         }
         return hashCode;

Modified: harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/DecimalFormat.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/DecimalFormat.java?rev=592434&r1=592433&r2=592434&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/DecimalFormat.java (original)
+++ harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/DecimalFormat.java Tue Nov  6 06:21:10 2007
@@ -54,7 +54,15 @@
      * default Locale.
      */
     public DecimalFormat() {
-        this(getPattern(Locale.getDefault(), "Number")); //$NON-NLS-1$
+        Locale locale = Locale.getDefault();
+        icuSymbols = new com.ibm.icu.text.DecimalFormatSymbols(locale);
+        symbols = new DecimalFormatSymbols(locale);
+        dform = new com.ibm.icu.text.DecimalFormat();
+
+        super.setMaximumFractionDigits(dform.getMaximumFractionDigits());
+        super.setMaximumIntegerDigits(dform.getMaximumIntegerDigits());
+        super.setMinimumFractionDigits(dform.getMinimumFractionDigits());
+        super.setMinimumIntegerDigits(dform.getMinimumIntegerDigits());
     }
 
     /**
@@ -68,7 +76,15 @@
      *                when the pattern cannot be parsed
      */
     public DecimalFormat(String pattern) {
-        this(pattern, new DecimalFormatSymbols());
+        Locale locale = Locale.getDefault();
+        icuSymbols = new com.ibm.icu.text.DecimalFormatSymbols(locale);
+        symbols = new DecimalFormatSymbols(locale);
+        dform = new com.ibm.icu.text.DecimalFormat(pattern, icuSymbols);
+
+        super.setMaximumFractionDigits(dform.getMaximumFractionDigits());
+        super.setMaximumIntegerDigits(dform.getMaximumIntegerDigits());
+        super.setMinimumFractionDigits(dform.getMinimumFractionDigits());
+        super.setMinimumIntegerDigits(dform.getMinimumIntegerDigits());
     }
 
     /**
@@ -85,7 +101,7 @@
      */
     public DecimalFormat(String pattern, DecimalFormatSymbols value) {
         symbols = (DecimalFormatSymbols) value.clone();
-        Locale locale = (Locale) this.getInternalField("locale", symbols); //$NON-NLS-1$
+        Locale locale = (Locale) Format.getInternalField("locale", symbols); //$NON-NLS-1$
         icuSymbols = new com.ibm.icu.text.DecimalFormatSymbols(locale);
         copySymbols(icuSymbols, symbols);
 
@@ -711,16 +727,16 @@
         fields.put("positiveSuffix", dform.getPositiveSuffix());
         fields.put("negativePrefix", dform.getNegativePrefix());
         fields.put("negativeSuffix", dform.getNegativeSuffix());
-        String posPrefixPattern = (String) this.getInternalField(
+        String posPrefixPattern = (String) Format.getInternalField(
                 "posPrefixPattern", dform);
         fields.put("posPrefixPattern", posPrefixPattern);
-        String posSuffixPattern = (String) this.getInternalField(
+        String posSuffixPattern = (String) Format.getInternalField(
                 "posSuffixPattern", dform);
         fields.put("posSuffixPattern", posSuffixPattern);
-        String negPrefixPattern = (String) this.getInternalField(
+        String negPrefixPattern = (String) Format.getInternalField(
                 "negPrefixPattern", dform);
         fields.put("negPrefixPattern", negPrefixPattern);
-        String negSuffixPattern = (String) this.getInternalField(
+        String negSuffixPattern = (String) Format.getInternalField(
                 "negSuffixPattern", dform);
         fields.put("negSuffixPattern", negSuffixPattern);
         fields.put("multiplier", dform.getMultiplier());
@@ -729,10 +745,10 @@
                 .isDecimalSeparatorAlwaysShown());
         fields.put("parseBigDecimal", parseBigDecimal);
         fields.put("symbols", symbols);
-        boolean useExponentialNotation = ((Boolean) this.getInternalField(
+        boolean useExponentialNotation = ((Boolean) Format.getInternalField(
                 "useExponentialNotation", dform)).booleanValue();
         fields.put("useExponentialNotation", useExponentialNotation);
-        byte minExponentDigits = ((Byte) this.getInternalField(
+        byte minExponentDigits = ((Byte) Format.getInternalField(
                 "minExponentDigits", dform)).byteValue();
         fields.put("minExponentDigits", minExponentDigits);
         fields.put("maximumIntegerDigits", dform.getMaximumIntegerDigits());
@@ -786,7 +802,7 @@
         int minimumFractionDigits = fields.get("minimumFractionDigits", 340);
         this.serialVersionOnStream = fields.get("serialVersionOnStream", 0);
 
-        Locale locale = (Locale) getInternalField("locale", symbols);
+        Locale locale = (Locale) Format.getInternalField("locale", symbols);
         dform = new com.ibm.icu.text.DecimalFormat("",
                 new com.ibm.icu.text.DecimalFormatSymbols(locale));
         setInternalField("useExponentialNotation", dform, Boolean
@@ -831,8 +847,14 @@
      */
     private void copySymbols(final com.ibm.icu.text.DecimalFormatSymbols icu,
             final DecimalFormatSymbols dfs) {
-        icu.setCurrency(com.ibm.icu.util.Currency.getInstance(dfs.getCurrency()
-                .getCurrencyCode()));
+        Currency currency = dfs.getCurrency();
+        if (currency == null) {
+            icu.setCurrency(com.ibm.icu.util.Currency.getInstance("XXX"));
+        } else {
+            icu.setCurrency(com.ibm.icu.util.Currency.getInstance(dfs
+                    .getCurrency().getCurrencyCode()));
+        }
+       
         icu.setCurrencySymbol(dfs.getCurrencySymbol());
         icu.setDecimalSeparator(dfs.getDecimalSeparator());
         icu.setDigit(dfs.getDigit());
@@ -873,32 +895,6 @@
                         return field;
                     }
                 });
-    }
-
-    /*
-     * Gets private field value by reflection.
-     * 
-     * @param fieldName the field name to be set @param target the object which
-     * field to be gotten
-     */
-    private Object getInternalField(final String fieldName, final Object target) {
-        Object value = AccessController
-                .doPrivileged(new PrivilegedAction<Object>() {
-                    public Object run() {
-                        Object result = null;
-                        java.lang.reflect.Field field = null;
-                        try {
-                            field = target.getClass().getDeclaredField(
-                                    fieldName);
-                            field.setAccessible(true);
-                            result = field.get(target);
-                        } catch (Exception e1) {
-                            return null;
-                        }
-                        return result;
-                    }
-                });
-        return value;
     }
 
 }

Modified: harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/DecimalFormatSymbols.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/DecimalFormatSymbols.java?rev=592434&r1=592433&r2=592434&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/DecimalFormatSymbols.java (original)
+++ harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/DecimalFormatSymbols.java Tue Nov  6 06:21:10 2007
@@ -19,13 +19,9 @@
 
 import java.io.IOException;
 import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.ObjectStreamField;
 import java.io.Serializable;
-import java.util.Arrays;
 import java.util.Currency;
 import java.util.Locale;
-import java.util.ResourceBundle;
 
 /**
  * DecimalFormatSymbols holds the symbols used in the formating and parsing of
@@ -35,18 +31,26 @@
 
     private static final long serialVersionUID = 5772796243397350300L;
 
-    private final int ZeroDigit = 0, Digit = 1, DecimalSeparator = 2,
-            GroupingSeparator = 3, PatternSeparator = 4, Percent = 5,
-            PerMill = 6, Exponent = 7, MonetaryDecimalSeparator = 8,
-            MinusSign = 9;
-
-    transient char[] patternChars;
-
+    private char zeroDigit;
+    private char groupingSeparator;
+    private char decimalSeparator;
+    private char perMill;
+    private char percent;
+    private char digit;
+    private char patternSeparator;
+    private String infinity;
+    private String NaN;
+    private char minusSign;
+    private String currencySymbol;
+    private String intlCurrencySymbol;
+    private char monetarySeparator;
+    private char exponential;
+    private Locale locale;
+    // 3 indicates version 5 and later
+    private int serialVersionOnStream = 3;
     private transient Currency currency;
 
-    private transient Locale locale;
-
-    private String infinity, NaN, currencySymbol, intlCurrencySymbol;
+    private transient com.ibm.icu.text.DecimalFormatSymbols icuSymbols;
 
     /**
      * Constructs a new DecimalFormatSymbols containing the symbols for the
@@ -64,20 +68,27 @@
      *            the Locale
      */
     public DecimalFormatSymbols(Locale locale) {
-        ResourceBundle bundle = Format.getBundle(locale);
-        patternChars = bundle.getString("DecimalPatternChars").toCharArray(); //$NON-NLS-1$
-        infinity = bundle.getString("Infinity"); //$NON-NLS-1$
-        NaN = bundle.getString("NaN"); //$NON-NLS-1$
+        icuSymbols = new com.ibm.icu.text.DecimalFormatSymbols(locale);
+        infinity = icuSymbols.getInfinity();
+        NaN = icuSymbols.getNaN();
         this.locale = locale;
-        try {
+        currencySymbol = icuSymbols.getCurrencySymbol();
+        intlCurrencySymbol = icuSymbols.getInternationalCurrencySymbol();
+        if (locale.getCountry().length() == 0) {
+            currency = Currency.getInstance("XXX");
+        } else {
             currency = Currency.getInstance(locale);
-            currencySymbol = currency.getSymbol(locale);
-            intlCurrencySymbol = currency.getCurrencyCode();
-        } catch (IllegalArgumentException e) {
-            currency = Currency.getInstance("XXX"); //$NON-NLS-1$
-            currencySymbol = bundle.getString("CurrencySymbol"); //$NON-NLS-1$
-            intlCurrencySymbol = bundle.getString("IntCurrencySymbol"); //$NON-NLS-1$
         }
+        zeroDigit = icuSymbols.getZeroDigit();
+        digit = icuSymbols.getDigit();
+        decimalSeparator = icuSymbols.getDecimalSeparator();
+        groupingSeparator = icuSymbols.getGroupingSeparator();
+        patternSeparator = icuSymbols.getPatternSeparator();
+        percent = icuSymbols.getPercent();
+        perMill = icuSymbols.getPerMill();
+        exponential = 'E';
+        monetarySeparator = icuSymbols.getMonetaryDecimalSeparator();
+        minusSign = icuSymbols.getMinusSign();
     }
 
     /**
@@ -92,7 +103,6 @@
     public Object clone() {
         try {
             DecimalFormatSymbols symbols = (DecimalFormatSymbols) super.clone();
-            symbols.patternChars = patternChars.clone();
             return symbols;
         } catch (CloneNotSupportedException e) {
             return null;
@@ -120,8 +130,15 @@
             return false;
         }
         DecimalFormatSymbols obj = (DecimalFormatSymbols) object;
-        return Arrays.equals(patternChars, obj.patternChars)
-                && infinity.equals(obj.infinity) && NaN.equals(obj.NaN)
+        return zeroDigit == obj.zeroDigit && digit == obj.digit
+                && decimalSeparator == obj.decimalSeparator
+                && groupingSeparator == obj.groupingSeparator
+                && patternSeparator == obj.patternSeparator
+                && percent == obj.percent && perMill == obj.perMill
+                && exponential == obj.exponential
+                && monetarySeparator == obj.monetarySeparator
+                && minusSign == obj.minusSign && infinity.equals(obj.infinity)
+                && NaN.equals(obj.NaN)
                 && currencySymbol.equals(obj.currencySymbol)
                 && intlCurrencySymbol.equals(obj.intlCurrencySymbol);
     }
@@ -134,8 +151,8 @@
      * with a value that is not a valid ISO 4217 currency code.
      * <p>
      *
-     * @return		the currency that was set in the constructor, <code>setCurrency()</code>,
-     * 				or <code>setInternationalCurrencySymbol()</code>, or </code>null</code>
+     * @return      the currency that was set in the constructor, <code>setCurrency()</code>,
+     *              or <code>setInternationalCurrencySymbol()</code>, or </code>null</code>
      * 
      * @see #setCurrency(Currency)
      * @see #setInternationalCurrencySymbol(String)
@@ -168,7 +185,7 @@
      * @return a char
      */
     public char getDecimalSeparator() {
-        return patternChars[DecimalSeparator];
+        return decimalSeparator;
     }
 
     /**
@@ -178,7 +195,7 @@
      * @return a char
      */
     public char getDigit() {
-        return patternChars[Digit];
+        return digit;
     }
 
     /**
@@ -187,7 +204,7 @@
      * @return a char
      */
     public char getGroupingSeparator() {
-        return patternChars[GroupingSeparator];
+        return groupingSeparator;
     }
 
     /**
@@ -201,7 +218,8 @@
 
     String getLocalPatternChars() {
         // Don't include the MonetaryDecimalSeparator or the MinusSign
-        return new String(patternChars, 0, patternChars.length - 2);
+        return new String(new char[]{zeroDigit, digit, decimalSeparator, groupingSeparator,
+                patternSeparator, percent, perMill, exponential});
     }
 
     /**
@@ -210,7 +228,7 @@
      * @return a char
      */
     public char getMinusSign() {
-        return patternChars[MinusSign];
+        return minusSign;
     }
 
     /**
@@ -220,7 +238,7 @@
      * @return a char
      */
     public char getMonetaryDecimalSeparator() {
-        return patternChars[MonetaryDecimalSeparator];
+        return monetarySeparator;
     }
 
     /**
@@ -239,7 +257,7 @@
      * @return a char
      */
     public char getPatternSeparator() {
-        return patternChars[PatternSeparator];
+        return patternSeparator;
     }
 
     /**
@@ -248,7 +266,7 @@
      * @return a char
      */
     public char getPercent() {
-        return patternChars[Percent];
+        return percent;
     }
 
     /**
@@ -257,7 +275,7 @@
      * @return a char
      */
     public char getPerMill() {
-        return patternChars[PerMill];
+        return perMill;
     }
 
     /**
@@ -266,11 +284,11 @@
      * @return a char
      */
     public char getZeroDigit() {
-        return patternChars[ZeroDigit];
+        return zeroDigit;
     }
 
     char getExponential() {
-        return patternChars[Exponent];
+        return exponential;
     }
 
     /**
@@ -283,9 +301,12 @@
      */
     @Override
     public int hashCode() {
-        return new String(patternChars).hashCode() + infinity.hashCode()
-                + NaN.hashCode() + currencySymbol.hashCode()
-                + intlCurrencySymbol.hashCode();
+        return new String(new char[] { zeroDigit, digit, decimalSeparator,
+                groupingSeparator, patternSeparator, percent, perMill,
+                exponential, monetarySeparator, minusSign }).hashCode()
+                + infinity.hashCode()
+                + NaN.hashCode()
+                + currencySymbol.hashCode() + intlCurrencySymbol.hashCode();
     }
 
     /**
@@ -361,7 +382,7 @@
      *            the decimal separator character
      */
     public void setDecimalSeparator(char value) {
-        patternChars[DecimalSeparator] = value;
+        decimalSeparator = value;
     }
 
     /**
@@ -371,7 +392,7 @@
      *            the digit character
      */
     public void setDigit(char value) {
-        patternChars[Digit] = value;
+        digit = value;
     }
 
     /**
@@ -381,7 +402,7 @@
      *            the grouping separator character
      */
     public void setGroupingSeparator(char value) {
-        patternChars[GroupingSeparator] = value;
+        groupingSeparator = value;
     }
 
     /**
@@ -401,7 +422,7 @@
      *            the minus sign character
      */
     public void setMinusSign(char value) {
-        patternChars[MinusSign] = value;
+        minusSign = value;
     }
 
     /**
@@ -412,7 +433,7 @@
      *            the monetary decimal separator character
      */
     public void setMonetaryDecimalSeparator(char value) {
-        patternChars[MonetaryDecimalSeparator] = value;
+        monetarySeparator = value;
     }
 
     /**
@@ -433,7 +454,7 @@
      *            the pattern separator character
      */
     public void setPatternSeparator(char value) {
-        patternChars[PatternSeparator] = value;
+        patternSeparator = value;
     }
 
     /**
@@ -443,7 +464,7 @@
      *            the percent character
      */
     public void setPercent(char value) {
-        patternChars[Percent] = value;
+        percent = value;
     }
 
     /**
@@ -453,7 +474,7 @@
      *            the mille percent character
      */
     public void setPerMill(char value) {
-        patternChars[PerMill] = value;
+        perMill = value;
     }
 
     /**
@@ -463,56 +484,16 @@
      *            the zero digit character
      */
     public void setZeroDigit(char value) {
-        patternChars[ZeroDigit] = value;
+        zeroDigit = value;
     }
 
     void setExponential(char value) {
-        patternChars[Exponent] = value;
-    }
-
-    private static final ObjectStreamField[] serialPersistentFields = {
-            new ObjectStreamField("currencySymbol", String.class), //$NON-NLS-1$
-            new ObjectStreamField("decimalSeparator", Character.TYPE), //$NON-NLS-1$
-            new ObjectStreamField("digit", Character.TYPE), //$NON-NLS-1$
-            new ObjectStreamField("exponential", Character.TYPE), //$NON-NLS-1$
-            new ObjectStreamField("groupingSeparator", Character.TYPE), //$NON-NLS-1$
-            new ObjectStreamField("infinity", String.class), //$NON-NLS-1$
-            new ObjectStreamField("intlCurrencySymbol", String.class), //$NON-NLS-1$
-            new ObjectStreamField("minusSign", Character.TYPE), //$NON-NLS-1$
-            new ObjectStreamField("monetarySeparator", Character.TYPE), //$NON-NLS-1$
-            new ObjectStreamField("NaN", String.class), //$NON-NLS-1$
-            new ObjectStreamField("patternSeparator", Character.TYPE), //$NON-NLS-1$
-            new ObjectStreamField("percent", Character.TYPE), //$NON-NLS-1$
-            new ObjectStreamField("perMill", Character.TYPE), //$NON-NLS-1$
-            new ObjectStreamField("serialVersionOnStream", Integer.TYPE), //$NON-NLS-1$
-            new ObjectStreamField("zeroDigit", Character.TYPE), //$NON-NLS-1$
-            new ObjectStreamField("locale", Locale.class), }; //$NON-NLS-1$
-
-    private void writeObject(ObjectOutputStream stream) throws IOException {
-        ObjectOutputStream.PutField fields = stream.putFields();
-        fields.put("currencySymbol", currencySymbol); //$NON-NLS-1$
-        fields.put("decimalSeparator", getDecimalSeparator()); //$NON-NLS-1$
-        fields.put("digit", getDigit()); //$NON-NLS-1$
-        fields.put("exponential", getExponential()); //$NON-NLS-1$
-        fields.put("groupingSeparator", getGroupingSeparator()); //$NON-NLS-1$
-        fields.put("infinity", infinity); //$NON-NLS-1$
-        fields.put("intlCurrencySymbol", intlCurrencySymbol); //$NON-NLS-1$
-        fields.put("minusSign", getMinusSign()); //$NON-NLS-1$
-        fields.put("monetarySeparator", getMonetaryDecimalSeparator()); //$NON-NLS-1$
-        fields.put("NaN", NaN); //$NON-NLS-1$
-        fields.put("patternSeparator", getPatternSeparator()); //$NON-NLS-1$
-        fields.put("percent", getPercent()); //$NON-NLS-1$
-        fields.put("perMill", getPerMill()); //$NON-NLS-1$
-        fields.put("serialVersionOnStream", 1); //$NON-NLS-1$
-        fields.put("zeroDigit", getZeroDigit()); //$NON-NLS-1$
-        fields.put("locale", locale); //$NON-NLS-1$
-        stream.writeFields();
+        exponential = value;
     }
 
     private void readObject(ObjectInputStream stream) throws IOException,
             ClassNotFoundException {
         ObjectInputStream.GetField fields = stream.readFields();
-        patternChars = new char[10];
         currencySymbol = (String) fields.get("currencySymbol", ""); //$NON-NLS-1$ //$NON-NLS-2$
         setDecimalSeparator(fields.get("decimalSeparator", '.')); //$NON-NLS-1$
         setDigit(fields.get("digit", '#')); //$NON-NLS-1$
@@ -539,5 +520,9 @@
         } catch (IllegalArgumentException e) {
             currency = null;
         }
+    }
+    
+    Locale getLocale(){
+        return locale;
     }
 }

Modified: harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/Format.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/Format.java?rev=592434&r1=592433&r2=592434&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/Format.java (original)
+++ harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/Format.java Tue Nov  6 06:21:10 2007
@@ -20,8 +20,6 @@
 import java.io.Serializable;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
-import java.util.Locale;
-import java.util.ResourceBundle;
 
 import org.apache.harmony.text.internal.nls.Messages;
 
@@ -56,17 +54,6 @@
         }
     }
 
-    static ResourceBundle getBundle(final Locale locale) {
-        return AccessController
-                .doPrivileged(new PrivilegedAction<ResourceBundle>() {
-                    public ResourceBundle run() {
-                        return ResourceBundle
-                                .getBundle(
-                                        "org.apache.harmony.luni.internal.locale.Locale", locale); //$NON-NLS-1$
-                    }
-                });
-    }
-
     String convertPattern(String template, String fromChars, String toChars,
             boolean check) {
         if (!check && fromChars.equals(toChars)) {
@@ -189,6 +176,32 @@
      * @return the object resulting from the parse, or null if there is an error
      */
     public abstract Object parseObject(String string, ParsePosition position);
+
+    /*
+     * Gets private field value by reflection.
+     * 
+     * @param fieldName the field name to be set @param target the object which
+     * field to be gotten
+     */
+    static Object getInternalField(final String fieldName, final Object target) {
+        Object value = AccessController
+                .doPrivileged(new PrivilegedAction<Object>() {
+                    public Object run() {
+                        Object result = null;
+                        java.lang.reflect.Field field = null;
+                        try {
+                            field = target.getClass().getDeclaredField(
+                                    fieldName);
+                            field.setAccessible(true);
+                            result = field.get(target);
+                        } catch (Exception e1) {
+                            return null;
+                        }
+                        return result;
+                    }
+                });
+        return value;
+    }
 
     static boolean upTo(String string, ParsePosition position,
             StringBuffer buffer, char stop) {

Modified: harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/NumberFormat.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/NumberFormat.java?rev=592434&r1=592433&r2=592434&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/NumberFormat.java (original)
+++ harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/NumberFormat.java Tue Nov  6 06:21:10 2007
@@ -24,7 +24,6 @@
 import java.io.ObjectStreamField;
 import java.util.Currency;
 import java.util.Locale;
-import java.util.ResourceBundle;
 
 import org.apache.harmony.text.internal.nls.Messages;
 
@@ -230,7 +229,10 @@
      * @return a NumberFormat
      */
     public static NumberFormat getCurrencyInstance(Locale locale) {
-        return getInstance(locale, "Currency"); //$NON-NLS-1$
+        com.ibm.icu.text.DecimalFormat icuFormat = (com.ibm.icu.text.DecimalFormat) com.ibm.icu.text.NumberFormat
+                .getCurrencyInstance(locale);
+        String pattern = icuFormat.toPattern();
+        return new DecimalFormat(pattern, new DecimalFormatSymbols(locale));
     }
 
     /**
@@ -252,9 +254,13 @@
      * @return a NumberFormat
      */
     public static NumberFormat getIntegerInstance(Locale locale) {
-        NumberFormat format = getInstance(locale, "Integer"); //$NON-NLS-1$
+        com.ibm.icu.text.DecimalFormat icuFormat = (com.ibm.icu.text.DecimalFormat) com.ibm.icu.text.NumberFormat
+                .getIntegerInstance(locale);
+        String pattern = icuFormat.toPattern();
+        DecimalFormat format = new DecimalFormat(pattern, new DecimalFormatSymbols(locale));
         format.setParseIntegerOnly(true);
         return format;
+        
     }
 
     /**
@@ -279,11 +285,6 @@
         return getNumberInstance(locale);
     }
 
-    static NumberFormat getInstance(Locale locale, String type) {
-        return new DecimalFormat(getPattern(locale, type),
-                new DecimalFormatSymbols(locale));
-    }
-
     /**
      * Answers the maximum number of fraction digits that are printed when
      * formatting. If the maximum is less than the number of fraction digits,
@@ -345,12 +346,10 @@
      * @return a NumberFormat
      */
     public static NumberFormat getNumberInstance(Locale locale) {
-        return getInstance(locale, "Number"); //$NON-NLS-1$
-    }
-
-    static String getPattern(Locale locale, String type) {
-        ResourceBundle bundle = getBundle(locale);
-        return bundle.getString(type);
+        com.ibm.icu.text.DecimalFormat icuFormat = (com.ibm.icu.text.DecimalFormat) com.ibm.icu.text.NumberFormat
+                .getNumberInstance(locale);
+        String pattern = icuFormat.toPattern();
+        return new DecimalFormat(pattern, new DecimalFormatSymbols(locale));
     }
 
     /**
@@ -372,7 +371,10 @@
      * @return a NumberFormat
      */
     public static NumberFormat getPercentInstance(Locale locale) {
-        return getInstance(locale, "Percent"); //$NON-NLS-1$
+        com.ibm.icu.text.DecimalFormat icuFormat = (com.ibm.icu.text.DecimalFormat) com.ibm.icu.text.NumberFormat
+                .getPercentInstance(locale);
+        String pattern = icuFormat.toPattern();
+        return new DecimalFormat(pattern, new DecimalFormatSymbols(locale));
     }
 
     /**



Mime
View raw message