harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ton...@apache.org
Subject svn commit: r596044 [2/3] - 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 Sun, 18 Nov 2007 03:24:27 GMT

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=596044&r1=596043&r2=596044&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/make/exclude.common (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/make/exclude.common Sat Nov 17 19:24:06 2007
@@ -1,7 +1,2 @@
 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=596044&r1=596043&r2=596044&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 Sat Nov 17 19:24:06 2007
@@ -129,13 +129,12 @@
 	 *            the locale
 	 */
 	protected Calendar(TimeZone timezone, Locale locale) {
-        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());
-    }
+		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());
+	}
 
 	/**
 	 * 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=596044&r1=596043&r2=596044&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 Sat Nov 17 19:24:06 2007
@@ -19,6 +19,8 @@
 
 import java.io.Serializable;
 
+import org.apache.harmony.luni.util.Msg;
+
 /**
  * This class represents a currency as identified in the ISO 4217 currency
  * codes.
@@ -31,6 +33,10 @@
 
     private String currencyCode;
 
+    private static String currencyVars = "EURO, HK, PREEURO"; //$NON-NLS-1$
+
+    private transient int defaultFractionDigits;
+
     /**
      * @param currencyCode
      */
@@ -54,7 +60,20 @@
         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);
         }
 
@@ -72,11 +91,21 @@
      *             if the locale's country is not a supported ISO 3166 Country
      */
     public static Currency getInstance(Locale locale) {
-        com.ibm.icu.util.Currency currency = com.ibm.icu.util.Currency.getInstance(locale);
-        if(currency == null) {
-            return null;
+        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$
         }
-        String currencyCode = currency.getCurrencyCode();
 
         if (currencyCode.equals("None")) { //$NON-NLS-1$
             return null;
@@ -132,7 +161,35 @@
         if (locale.getCountry().equals("")) { //$NON-NLS-1$
             return currencyCode;
         }
-        return com.ibm.icu.util.Currency.getInstance(currencyCode).getSymbol(locale);
+
+        // 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;
     }
 
     /**
@@ -143,7 +200,7 @@
      * @return the default number of fraction digits for this currency
      */
     public int getDefaultFractionDigits() {
-        return com.ibm.icu.util.Currency.getInstance(currencyCode).getDefaultFractionDigits();
+        return defaultFractionDigits;
     }
 
     /**

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=596044&r1=596043&r2=596044&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 Sat Nov 17 19:24:06 2007
@@ -24,12 +24,14 @@
 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 com.ibm.icu.util.ULocale;
+import org.apache.harmony.luni.util.Util;
 
 /**
  * Locale represents a language/country/variant combination. It is an identifier
@@ -44,6 +46,8 @@
 	
 	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();
@@ -170,8 +174,6 @@
     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.
@@ -216,14 +218,7 @@
         if (language == null || country == null || variant == null) {
             throw new NullPointerException();
         }
-        if(language.length() == 0 && country.length() == 0){
-            languageCode = "";
-            countryCode = "";
-            variantCode = variant;
-            return;
-        }
-        this.uLocale = new ULocale(language, country, variant);
-        languageCode = uLocale.getLanguage();
+        languageCode = Util.toASCIILowerCase(language);
         // Map new language codes to the obsolete language
         // codes so the correct resource bundles will be used.
         if (languageCode.equals("he")) {//$NON-NLS-1$
@@ -235,9 +230,9 @@
         }
 
         // countryCode is defined in ASCII character set
-        countryCode = uLocale.getCountry();
+        countryCode = Util.toASCIIUpperCase(country);
 
-        variantCode = uLocale.getVariant();
+        variantCode = variant;
     }
 
 	/**
@@ -372,12 +367,15 @@
 	 * @return an array of Locale
 	 */
 	public static Locale[] getAvailableLocales() {
-		ULocale[] ulocales =  ULocale.getAvailableLocales();
-        Locale[] locales = new Locale[ulocales.length];
-        for (int i = 0; i < locales.length; i++) {
-            locales[i] = ulocales[i].toLocale();
+		if (availableLocales == null) {
+            availableLocales = AccessController
+                    .doPrivileged(new PrivilegedAction<Locale[]>() {
+                        public Locale[] run() {
+                            return find("org/apache/harmony/luni/internal/locale/Locale_"); //$NON-NLS-1$
+                        }
+                    });
         }
-        return locales;
+		return availableLocales.clone();
 	}
 
 	/**
@@ -419,7 +417,24 @@
 	 * @return a country name
 	 */
 	public String getDisplayCountry(Locale locale) {
-		return ULocale.forLocale(this).getDisplayCountry(ULocale.forLocale(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;
+		}
 	}
 
 	/**
@@ -443,7 +458,24 @@
 	 * @return a language name
 	 */
 	public String getDisplayLanguage(Locale locale) {
-        return ULocale.forLocale(this).getDisplayLanguage(ULocale.forLocale(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;
+		}
 	}
 
 	/**
@@ -514,7 +546,31 @@
 	 * @return a variant name
 	 */
 	public String getDisplayVariant(Locale locale) {
-        return ULocale.forLocale(this).getDisplayVariant(ULocale.forLocale(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();
 	}
 
 	/**
@@ -527,7 +583,11 @@
 	 *                when there is no matching three letter ISO country code
 	 */
 	public String getISO3Country() throws MissingResourceException {
-        return ULocale.forLocale(this).getISO3Country();
+		if (countryCode.length() == 0) {
+            return ""; //$NON-NLS-1$
+        }
+		ResourceBundle bundle = getBundle("ISO3Countries", this); //$NON-NLS-1$
+		return bundle.getString(countryCode);
 	}
 
 	/**
@@ -540,7 +600,11 @@
 	 *                when there is no matching three letter ISO language code
 	 */
 	public String getISO3Language() throws MissingResourceException {
-        return ULocale.forLocale(this).getISO3Language();
+		if (languageCode.length() == 0) {
+            return ""; //$NON-NLS-1$
+        }
+		ResourceBundle bundle = getBundle("ISO3Languages", this); //$NON-NLS-1$
+		return bundle.getString(languageCode);
 	}
 
 	/**
@@ -550,7 +614,18 @@
 	 * @return an array of String
 	 */
 	public static String[] getISOCountries() {
-        return ULocale.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;
     }
 
 	/**
@@ -560,7 +635,14 @@
 	 * @return an array of String
 	 */
 	public static String[] getISOLanguages() {
-        return ULocale.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;
 	}
 
 	/**
@@ -639,6 +721,15 @@
 			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/SimpleTimeZone.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/SimpleTimeZone.java?rev=596044&r1=596043&r2=596044&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/SimpleTimeZone.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/SimpleTimeZone.java Sat Nov 17 19:24:06 2007
@@ -69,10 +69,6 @@
 
 	private int dstSavings = 3600000;
 
-    private transient com.ibm.icu.util.TimeZone icuTZ;
-    
-    private boolean isSimple;
-
 	/**
 	 * Constructs a new SimpleTimeZone using the specified offset for standard
 	 * time from GMT and the specified time zone ID.
@@ -82,15 +78,10 @@
 	 * @param name
 	 *            the time zone ID
 	 */
-    public SimpleTimeZone(int offset, String name) {
-        setID(name);
-        rawOffset = offset;
-        icuTZ = com.ibm.icu.util.TimeZone.getTimeZone(name);
-        if (icuTZ instanceof com.ibm.icu.util.SimpleTimeZone) {
-            isSimple = true;
-            icuTZ.setRawOffset(offset);
-        }
-    }
+	public SimpleTimeZone(int offset, String name) {
+		setID(name);
+		rawOffset = offset;
+	}
 
 	/**
 	 * Constructs a new SimpleTimeZone using the specified offset for standard
@@ -165,27 +156,18 @@
 	 * @param daylightSavings
 	 *            the daylight savings time difference in milliseconds
 	 */
-    public SimpleTimeZone(int offset, String name, int startMonth,
-            int startDay, int startDayOfWeek, int startTime, int endMonth,
-            int endDay, int endDayOfWeek, int endTime, int daylightSavings) {
-        icuTZ = com.ibm.icu.util.TimeZone.getTimeZone(name);
-        if (icuTZ instanceof com.ibm.icu.util.SimpleTimeZone) {
-            isSimple = true;
-            icuTZ = new com.ibm.icu.util.SimpleTimeZone(offset, name,
-                    startMonth, startDay, startDayOfWeek, startTime, endMonth,
-                    endDay, endDayOfWeek, endTime, daylightSavings);
-        }
-        setID(name);
-        rawOffset = offset;
-        if (daylightSavings <= 0) {
-            throw new IllegalArgumentException(Msg.getString(
-                    "K00e9", daylightSavings)); //$NON-NLS-1$
+	public SimpleTimeZone(int offset, String name, int startMonth,
+			int startDay, int startDayOfWeek, int startTime, int endMonth,
+			int endDay, int endDayOfWeek, int endTime, int daylightSavings) {
+		this(offset, name);
+		if (daylightSavings <= 0) {
+            throw new IllegalArgumentException(Msg.getString("K00e9", daylightSavings)); //$NON-NLS-1$
         }
-        dstSavings = daylightSavings;
+		dstSavings = daylightSavings;
 
-        setStartRule(startMonth, startDay, startDayOfWeek, startTime);
-        setEndRule(endMonth, endDay, endDayOfWeek, endTime);
-    }
+		setStartRule(startMonth, startDay, startDayOfWeek, startTime);
+		setEndRule(endMonth, endDay, endDayOfWeek, endTime);
+	}
 
 	/**
 	 * Constructs a new SimpleTimeZone using the specified offset for standard
@@ -321,16 +303,132 @@
 	 */
 	@Override
     public int getOffset(int era, int year, int month, int day, int dayOfWeek,
-            int time) {
-        if (era != GregorianCalendar.BC && era != GregorianCalendar.AD) {
+			int time) {
+		if (era != GregorianCalendar.BC && era != GregorianCalendar.AD) {
             throw new IllegalArgumentException(Msg.getString("K00ea", era)); //$NON-NLS-1$
         }
-        checkRange(month, dayOfWeek, time);
-        if (month != Calendar.FEBRUARY || day != 29 || !isLeapYear(year)) {
+		checkRange(month, dayOfWeek, time);
+		if (month != Calendar.FEBRUARY || day != 29 || !isLeapYear(year)) {
             checkDay(month, day);
         }
-        return icuTZ.getOffset(era, year, month, day, dayOfWeek, time);
-    }
+
+		if (!useDaylightTime() || era != GregorianCalendar.AD
+				|| year < startYear) {
+            return rawOffset;
+        }
+		if (endMonth < startMonth) {
+			if (month > endMonth && month < startMonth) {
+                return rawOffset;
+            }
+		} else {
+			if (month < startMonth || month > endMonth) {
+                return rawOffset;
+            }
+		}
+
+		int ruleDay = 0, daysInMonth, firstDayOfMonth = mod7(dayOfWeek - day);
+		if (month == startMonth) {
+			switch (startMode) {
+			case DOM_MODE:
+				ruleDay = startDay;
+				break;
+			case DOW_IN_MONTH_MODE:
+				if (startDay >= 0) {
+					ruleDay = mod7(startDayOfWeek - firstDayOfMonth) + 1
+							+ (startDay - 1) * 7;
+				} else {
+					daysInMonth = GregorianCalendar.DaysInMonth[startMonth];
+					if (startMonth == Calendar.FEBRUARY && isLeapYear(year)) {
+                        daysInMonth += 1;
+                    }
+					ruleDay = daysInMonth
+							+ 1
+							+ mod7(startDayOfWeek
+									- (firstDayOfMonth + daysInMonth))
+							+ startDay * 7;
+				}
+				break;
+			case DOW_GE_DOM_MODE:
+				ruleDay = startDay
+						+ mod7(startDayOfWeek
+								- (firstDayOfMonth + startDay - 1));
+				break;
+			case DOW_LE_DOM_MODE:
+				ruleDay = startDay
+						+ mod7(startDayOfWeek
+								- (firstDayOfMonth + startDay - 1));
+				if (ruleDay != startDay) {
+                    ruleDay -= 7;
+                }
+				break;
+			}
+			if (ruleDay > day || ruleDay == day && time < startTime) {
+                return rawOffset;
+            }
+		}
+
+		int ruleTime = endTime - dstSavings;
+		int nextMonth = (month + 1) % 12;
+		if (month == endMonth || (ruleTime < 0 && nextMonth == endMonth)) {
+			switch (endMode) {
+			case DOM_MODE:
+				ruleDay = endDay;
+				break;
+			case DOW_IN_MONTH_MODE:
+				if (endDay >= 0) {
+					ruleDay = mod7(endDayOfWeek - firstDayOfMonth) + 1
+							+ (endDay - 1) * 7;
+				} else {
+					daysInMonth = GregorianCalendar.DaysInMonth[endMonth];
+					if (endMonth == Calendar.FEBRUARY && isLeapYear(year)) {
+                        daysInMonth++;
+                    }
+					ruleDay = daysInMonth
+							+ 1
+							+ mod7(endDayOfWeek
+									- (firstDayOfMonth + daysInMonth)) + endDay
+							* 7;
+				}
+				break;
+			case DOW_GE_DOM_MODE:
+				ruleDay = endDay
+						+ mod7(endDayOfWeek - (firstDayOfMonth + endDay - 1));
+				break;
+			case DOW_LE_DOM_MODE:
+				ruleDay = endDay
+						+ mod7(endDayOfWeek - (firstDayOfMonth + endDay - 1));
+				if (ruleDay != endDay) {
+                    ruleDay -= 7;
+                }
+				break;
+			}
+
+			int ruleMonth = endMonth;
+			if (ruleTime < 0) {
+				int changeDays = 1 - (ruleTime / 86400000);
+				ruleTime = (ruleTime % 86400000) + 86400000;
+				ruleDay -= changeDays;
+				if (ruleDay <= 0) {
+					if (--ruleMonth < Calendar.JANUARY) {
+                        ruleMonth = Calendar.DECEMBER;
+                    }
+					ruleDay += GregorianCalendar.DaysInMonth[ruleMonth];
+					if (ruleMonth == Calendar.FEBRUARY && isLeapYear(year)) {
+                        ruleDay++;
+                    }
+				}
+			}
+
+			if (month == ruleMonth) {
+				if (ruleDay < day || ruleDay == day && time >= ruleTime) {
+                    return rawOffset;
+                }
+			} else if (nextMonth != ruleMonth) {
+                return rawOffset;
+            }
+		}
+		return rawOffset + dstSavings;
+	}
 
 	/**
 	 * Gets the offset from GMT of this SimpleTimeZone for the specified date.
@@ -343,7 +441,13 @@
 	 */
 	@Override
     public int getOffset(long time) {
-        return icuTZ.getOffset(time);
+		if (!useDaylightTime()) {
+            return rawOffset;
+        }
+		if (daylightSavings == null) {
+            daylightSavings = new GregorianCalendar(this);
+        }
+		return daylightSavings.getOffset(time + rawOffset);
 	}
 
 	/**
@@ -416,7 +520,15 @@
 	 */
 	@Override
     public boolean inDaylightTime(Date time) {
-		return icuTZ.inDaylightTime(time);
+		// check for null pointer
+		long millis = time.getTime();
+		if (!useDaylightTime()) {
+            return false;
+        }
+		if (daylightSavings == null) {
+            daylightSavings = new GregorianCalendar(this);
+        }
+		return daylightSavings.getOffset(millis + rawOffset) != rawOffset;
 	}
 
 	private boolean isLeapYear(int year) {
@@ -426,6 +538,11 @@
         return year % 4 == 0;
 	}
 
+	private int mod7(int num1) {
+		int rem = num1 % 7;
+		return (num1 < 0 && rem < 0) ? 7 + rem : rem;
+	}
+
 	/**
 	 * Sets the daylight savings offset in milliseconds for this SimpleTimeZone.
 	 * 
@@ -503,13 +620,10 @@
 	 */
 	public void setEndRule(int month, int dayOfMonth, int time) {
 		endMonth = month;
-        endDay = dayOfMonth;
-        endDayOfWeek = 0; // Initialize this value for hasSameRules()
-        endTime = time;
-        setEndMode();
-        if (isSimple) {
-            ((com.ibm.icu.util.SimpleTimeZone) icuTZ).setEndRule(month, dayOfMonth, time);
-        }
+		endDay = dayOfMonth;
+		endDayOfWeek = 0; // Initialize this value for hasSameRules()
+		endTime = time;
+		setEndMode();
 	}
 
 	/**
@@ -533,9 +647,6 @@
 		endDayOfWeek = dayOfWeek;
 		endTime = time;
 		setEndMode();
-        if (isSimple) {
-            ((com.ibm.icu.util.SimpleTimeZone) icuTZ).setEndRule(month, day, dayOfWeek, time);
-        }
 	}
 
 	/**
@@ -561,9 +672,6 @@
 		endDayOfWeek = -dayOfWeek;
 		endTime = time;
 		setEndMode();
-        if (isSimple) {
-            ((com.ibm.icu.util.SimpleTimeZone) icuTZ).setEndRule(month, day, dayOfWeek, time, after);
-        }
 	}
 
 	/**
@@ -626,9 +734,6 @@
 		startDayOfWeek = 0; // Initialize this value for hasSameRules()
 		startTime = time;
 		setStartMode();
-        if (isSimple) {
-            ((com.ibm.icu.util.SimpleTimeZone) icuTZ).setStartRule(month, dayOfMonth, time);
-        }
 	}
 
 	/**
@@ -652,9 +757,6 @@
 		startDayOfWeek = dayOfWeek;
 		startTime = time;
 		setStartMode();
-        if (isSimple) {
-            ((com.ibm.icu.util.SimpleTimeZone) icuTZ).setStartRule(month, day, dayOfWeek, time);
-        }
 	}
 
 	/**
@@ -680,9 +782,6 @@
 		startDayOfWeek = -dayOfWeek;
 		startTime = time;
 		setStartMode();
-        if (isSimple) {
-            ((com.ibm.icu.util.SimpleTimeZone) icuTZ).setStartRule(month, day, dayOfWeek, time, after);
-        }
 	}
 
 	/**
@@ -738,7 +837,7 @@
 	 */
 	@Override
     public boolean useDaylightTime() {
-		return icuTZ.useDaylightTime();
+		return useDaylight;
 	}
 
 	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=596044&r1=596043&r2=596044&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 Sat Nov 17 19:24:06 2007
@@ -20,7 +20,6 @@
 
 import java.io.Serializable;
 import java.security.AccessController;
-import java.security.PrivilegedAction;
 import java.text.DateFormatSymbols;
 
 import org.apache.harmony.luni.util.PriviAction;
@@ -447,9 +446,8 @@
 	 */
 	public static synchronized void setDefault(TimeZone timezone) {
 		if (timezone != null) {
-            setICUDefaultTimeZone(timezone);
-            Default = timezone;
-            return;
+			Default = timezone;
+			return;
 		}
 
 		String zone = AccessController.doPrivileged(new PriviAction<String>(
@@ -483,31 +481,9 @@
 			}
 		} else {
 			// if property user.timezone is set in command line (with -D option)
-		    Default = getTimeZone(zone);
+			Default = getTimeZone(zone);
 		}
-		setICUDefaultTimeZone(Default);
 	}
-
-    private static void setICUDefaultTimeZone(TimeZone timezone) {
-        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;
-                    }
-                });
-    }
 
 	/**
 	 * Sets the ID of this TimeZone.

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=596044&r1=596043&r2=596044&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 Sat Nov 17 19:24:06 2007
@@ -436,13 +436,12 @@
 		TimeZone tz = TimeZone.getDefault();
 		TimeZone.setDefault(TimeZone.getTimeZone("EST"));
 		try {
-            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);
-        }
+			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);
+		}
 	}
 
 	/**

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/tests/api/java/util/GregorianCalendarTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/tests/api/java/util/GregorianCalendarTest.java?rev=596044&r1=596043&r2=596044&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/tests/api/java/util/GregorianCalendarTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/tests/api/java/util/GregorianCalendarTest.java Sat Nov 17 19:24:06 2007
@@ -199,23 +199,23 @@
 		gc1 = new GregorianCalendar(TimeZone.getTimeZone("EST"));
 		gc1.set(1999, Calendar.APRIL, 3, 16, 0); // day before DST change
 		gc1.add(Calendar.MILLISECOND, 24 * 60 * 60 * 1000);
-		assertEquals("Wrong time after MILLISECOND change", 16, gc1
+		assertEquals("Wrong time after MILLISECOND change", 17, gc1
 				.get(Calendar.HOUR_OF_DAY));
 		gc1.set(1999, Calendar.APRIL, 3, 16, 0); // day before DST change
 		gc1.add(Calendar.SECOND, 24 * 60 * 60);
-		assertEquals("Wrong time after SECOND change", 16, gc1
+		assertEquals("Wrong time after SECOND change", 17, gc1
 				.get(Calendar.HOUR_OF_DAY));
 		gc1.set(1999, Calendar.APRIL, 3, 16, 0); // day before DST change
 		gc1.add(Calendar.MINUTE, 24 * 60);
-		assertEquals("Wrong time after MINUTE change", 16, gc1
+		assertEquals("Wrong time after MINUTE change", 17, gc1
 				.get(Calendar.HOUR_OF_DAY));
 		gc1.set(1999, Calendar.APRIL, 3, 16, 0); // day before DST change
 		gc1.add(Calendar.HOUR, 24);
-		assertEquals("Wrong time after HOUR change", 16, gc1
+		assertEquals("Wrong time after HOUR change", 17, gc1
 				.get(Calendar.HOUR_OF_DAY));
 		gc1.set(1999, Calendar.APRIL, 3, 16, 0); // day before DST change
 		gc1.add(Calendar.HOUR_OF_DAY, 24);
-		assertEquals("Wrong time after HOUR_OF_DAY change", 16, gc1
+		assertEquals("Wrong time after HOUR_OF_DAY change", 17, gc1
 				.get(Calendar.HOUR_OF_DAY));
 
 		gc1.set(1999, Calendar.APRIL, 3, 16, 0); // day before DST change

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/tests/api/java/util/SimpleTimeZoneTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/tests/api/java/util/SimpleTimeZoneTest.java?rev=596044&r1=596043&r2=596044&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/tests/api/java/util/SimpleTimeZoneTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/tests/api/java/util/SimpleTimeZoneTest.java Sat Nov 17 19:24:06 2007
@@ -189,15 +189,15 @@
 	public void test_getOffsetIIIIII() {
 		// Test for method int java.util.SimpleTimeZone.getOffset(int, int, int,
 		// int, int, int)
-		TimeZone st1 = TimeZone.getTimeZone("EST");
+		st1 = (SimpleTimeZone) TimeZone.getTimeZone("EST");
 		assertTrue("Incorrect offset returned", st1.getOffset(
 				GregorianCalendar.AD, 1998, Calendar.NOVEMBER, 11,
 				Calendar.WEDNESDAY, 0) == -(5 * 60 * 60 * 1000));
 
-        st1 = TimeZone.getTimeZone("EST");
-        assertEquals("Incorrect offset returned", -(5 * 60 * 60 * 1000), st1
-                .getOffset(GregorianCalendar.AD, 1998, Calendar.JUNE, 11,
-                        Calendar.THURSDAY, 0));
+		st1 = (SimpleTimeZone) TimeZone.getTimeZone("EST");
+		assertTrue("Incorrect offset returned", st1.getOffset(
+				GregorianCalendar.AD, 1998, Calendar.JUNE, 11,
+				Calendar.THURSDAY, 0) == -(4 * 60 * 60 * 1000));
 	}
 
 	/**
@@ -251,9 +251,9 @@
 	public void test_inDaylightTimeLjava_util_Date() {
 		// Test for method boolean
 		// java.util.SimpleTimeZone.inDaylightTime(java.util.Date)
-		TimeZone zone = TimeZone.getTimeZone("EST");
+		SimpleTimeZone zone = (SimpleTimeZone) TimeZone.getTimeZone("EST");
 		GregorianCalendar gc = new GregorianCalendar(1998, Calendar.JUNE, 11);
-		assertFalse("Returned incorrect daylight value1", zone.inDaylightTime(gc
+		assertTrue("Returned incorrect daylight value1", zone.inDaylightTime(gc
 				.getTime()));
 		gc = new GregorianCalendar(1998, Calendar.NOVEMBER, 11);
 		assertTrue("Returned incorrect daylight value2", !(zone
@@ -263,20 +263,20 @@
 		assertTrue("Returned incorrect daylight value3", !(zone
 				.inDaylightTime(gc.getTime())));
 		Date date = new Date(gc.getTime().getTime() + 1000);
-		assertFalse("Returned incorrect daylight value4", zone
+		assertTrue("Returned incorrect daylight value4", zone
 				.inDaylightTime(date));
 		gc.set(1999, Calendar.OCTOBER, 31, 1, 0, 0);
 		assertTrue("Returned incorrect daylight value5", !(zone
 				.inDaylightTime(gc.getTime())));
 		date = new Date(gc.getTime().getTime() - 1000);
-		assertFalse("Returned incorrect daylight value6", zone
+		assertTrue("Returned incorrect daylight value6", zone
 				.inDaylightTime(date));
 
 		assertTrue("Returned incorrect daylight value7", !zone
 				.inDaylightTime(new Date(891752400000L + 7200000 - 1)));
-		assertFalse("Returned incorrect daylight value8", zone
+		assertTrue("Returned incorrect daylight value8", zone
 				.inDaylightTime(new Date(891752400000L + 7200000)));
-		assertFalse("Returned incorrect daylight value9", zone
+		assertTrue("Returned incorrect daylight value9", zone
 				.inDaylightTime(new Date(909288000000L + 7200000 - 1)));
 		assertTrue("Returned incorrect daylight value10", !zone
 				.inDaylightTime(new Date(909288000000L + 7200000)));
@@ -329,7 +329,7 @@
 	public void test_setEndRuleIIIIZ() {
 		// Test for method void java.util.SimpleTimeZone.setEndRule(int, int,
 		// int, int, boolean)
-		SimpleTimeZone st = new SimpleTimeZone(1000, "Test_TZ");
+		SimpleTimeZone st = (SimpleTimeZone) TimeZone.getDefault().clone();
 		// Spec indicates that both end and start must be set or result is
 		// undefined
 		st.setStartRule(Calendar.NOVEMBER, 8, Calendar.SUNDAY, 1, false);
@@ -410,7 +410,7 @@
 	public void test_setStartRuleIIIIZ() {
 		// Test for method void java.util.SimpleTimeZone.setStartRule(int, int,
 		// int, int, boolean)
-		SimpleTimeZone st = new SimpleTimeZone(0, "Test"); ;
+		SimpleTimeZone st = (SimpleTimeZone) TimeZone.getDefault().clone();
 		// Spec indicates that both end and start must be set or result is
 		// undefined
 		st.setStartRule(Calendar.NOVEMBER, 1, Calendar.SUNDAY, 1, true);

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/tests/api/java/util/TimeZoneTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/tests/api/java/util/TimeZoneTest.java?rev=596044&r1=596043&r2=596044&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/tests/api/java/util/TimeZoneTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/tests/api/java/util/TimeZoneTest.java Sat Nov 17 19:24:06 2007
@@ -80,7 +80,7 @@
 				.getTimeInMillis();
 		st1 = TimeZone.getTimeZone("EST");
 		assertEquals("T2. Incorrect offset returned",
-                             -(5 * ONE_HOUR), st1.getOffset(time2));
+                             -(4 * ONE_HOUR), st1.getOffset(time2));
 
 		// test on subclass Support_TimeZone, an instance with daylight savings
 		TimeZone tz1 = new Support_TimeZone(-5 * ONE_HOUR, true);

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=596044&r1=596043&r2=596044&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/text/make/exclude.common (original)
+++ harmony/enhanced/classlib/trunk/modules/text/make/exclude.common Sat Nov 17 19:24:06 2007
@@ -1,5 +1,2 @@
 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=596044&r1=596043&r2=596044&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 Sat Nov 17 19:24:06 2007
@@ -22,6 +22,7 @@
 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;
@@ -320,8 +321,9 @@
      */
     public final static DateFormat getDateInstance(int style, Locale locale) {
         checkDateStyle(style);
-        com.ibm.icu.text.DateFormat icuFormat = com.ibm.icu.text.DateFormat.getDateInstance(style, locale);
-        return new SimpleDateFormat(locale, (com.ibm.icu.text.SimpleDateFormat)icuFormat);
+        ResourceBundle bundle = getBundle(locale);
+        String pattern = bundle.getString("Date_" + getStyleName(style)); //$NON-NLS-1$
+        return new SimpleDateFormat(pattern, locale);
     }
 
     /**
@@ -368,8 +370,10 @@
             int timeStyle, Locale locale) {
         checkTimeStyle(timeStyle);
         checkDateStyle(dateStyle);
-        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);
+        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);
     }
 
     /**
@@ -447,8 +451,9 @@
      */
     public final static DateFormat getTimeInstance(int style, Locale locale) {
         checkTimeStyle(style);
-        com.ibm.icu.text.DateFormat icuFormat = com.ibm.icu.text.DateFormat.getTimeInstance(style, locale);
-        return new SimpleDateFormat(locale, (com.ibm.icu.text.SimpleDateFormat)icuFormat);
+        ResourceBundle bundle = getBundle(locale);
+        String pattern = bundle.getString("Time_" + getStyleName(style)); //$NON-NLS-1$
+        return new SimpleDateFormat(pattern, locale);
     }
 
     /**

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=596044&r1=596043&r2=596044&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 Sat Nov 17 19:24:06 2007
@@ -20,6 +20,7 @@
 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
@@ -51,16 +52,15 @@
      *            the Locale
      */
     public DateFormatSymbols(Locale locale) {
-        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();
+        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$
     }
 
     /**
@@ -273,9 +273,7 @@
         }
         for (String[] element : zoneStrings) {
             for (int j = 0; j < element.length; j++) {
-                if (element[j] != null) {
-                    hashCode += element[j].hashCode();
-                }
+                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=596044&r1=596043&r2=596044&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 Sat Nov 17 19:24:06 2007
@@ -54,15 +54,7 @@
      * default Locale.
      */
     public DecimalFormat() {
-        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());
+        this(getPattern(Locale.getDefault(), "Number")); //$NON-NLS-1$
     }
 
     /**
@@ -76,15 +68,7 @@
      *                when the pattern cannot be parsed
      */
     public DecimalFormat(String pattern) {
-        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());
+        this(pattern, new DecimalFormatSymbols());
     }
 
     /**
@@ -101,7 +85,7 @@
      */
     public DecimalFormat(String pattern, DecimalFormatSymbols value) {
         symbols = (DecimalFormatSymbols) value.clone();
-        Locale locale = (Locale) Format.getInternalField("locale", symbols); //$NON-NLS-1$
+        Locale locale = (Locale) this.getInternalField("locale", symbols); //$NON-NLS-1$
         icuSymbols = new com.ibm.icu.text.DecimalFormatSymbols(locale);
         copySymbols(icuSymbols, symbols);
 
@@ -727,16 +711,16 @@
         fields.put("positiveSuffix", dform.getPositiveSuffix());
         fields.put("negativePrefix", dform.getNegativePrefix());
         fields.put("negativeSuffix", dform.getNegativeSuffix());
-        String posPrefixPattern = (String) Format.getInternalField(
+        String posPrefixPattern = (String) this.getInternalField(
                 "posPrefixPattern", dform);
         fields.put("posPrefixPattern", posPrefixPattern);
-        String posSuffixPattern = (String) Format.getInternalField(
+        String posSuffixPattern = (String) this.getInternalField(
                 "posSuffixPattern", dform);
         fields.put("posSuffixPattern", posSuffixPattern);
-        String negPrefixPattern = (String) Format.getInternalField(
+        String negPrefixPattern = (String) this.getInternalField(
                 "negPrefixPattern", dform);
         fields.put("negPrefixPattern", negPrefixPattern);
-        String negSuffixPattern = (String) Format.getInternalField(
+        String negSuffixPattern = (String) this.getInternalField(
                 "negSuffixPattern", dform);
         fields.put("negSuffixPattern", negSuffixPattern);
         fields.put("multiplier", dform.getMultiplier());
@@ -745,10 +729,10 @@
                 .isDecimalSeparatorAlwaysShown());
         fields.put("parseBigDecimal", parseBigDecimal);
         fields.put("symbols", symbols);
-        boolean useExponentialNotation = ((Boolean) Format.getInternalField(
+        boolean useExponentialNotation = ((Boolean) this.getInternalField(
                 "useExponentialNotation", dform)).booleanValue();
         fields.put("useExponentialNotation", useExponentialNotation);
-        byte minExponentDigits = ((Byte) Format.getInternalField(
+        byte minExponentDigits = ((Byte) this.getInternalField(
                 "minExponentDigits", dform)).byteValue();
         fields.put("minExponentDigits", minExponentDigits);
         fields.put("maximumIntegerDigits", dform.getMaximumIntegerDigits());
@@ -802,7 +786,7 @@
         int minimumFractionDigits = fields.get("minimumFractionDigits", 340);
         this.serialVersionOnStream = fields.get("serialVersionOnStream", 0);
 
-        Locale locale = (Locale) Format.getInternalField("locale", symbols);
+        Locale locale = (Locale) getInternalField("locale", symbols);
         dform = new com.ibm.icu.text.DecimalFormat("",
                 new com.ibm.icu.text.DecimalFormatSymbols(locale));
         setInternalField("useExponentialNotation", dform, Boolean
@@ -847,14 +831,8 @@
      */
     private void copySymbols(final com.ibm.icu.text.DecimalFormatSymbols icu,
             final DecimalFormatSymbols dfs) {
-        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.setCurrency(com.ibm.icu.util.Currency.getInstance(dfs.getCurrency()
+                .getCurrencyCode()));
         icu.setCurrencySymbol(dfs.getCurrencySymbol());
         icu.setDecimalSeparator(dfs.getDecimalSeparator());
         icu.setDigit(dfs.getDigit());
@@ -895,6 +873,32 @@
                         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=596044&r1=596043&r2=596044&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 Sat Nov 17 19:24:06 2007
@@ -19,9 +19,13 @@
 
 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
@@ -31,26 +35,18 @@
 
     private static final long serialVersionUID = 5772796243397350300L;
 
-    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 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 transient Currency currency;
 
-    private transient com.ibm.icu.text.DecimalFormatSymbols icuSymbols;
+    private transient Locale locale;
+
+    private String infinity, NaN, currencySymbol, intlCurrencySymbol;
 
     /**
      * Constructs a new DecimalFormatSymbols containing the symbols for the
@@ -68,27 +64,20 @@
      *            the Locale
      */
     public DecimalFormatSymbols(Locale locale) {
-        icuSymbols = new com.ibm.icu.text.DecimalFormatSymbols(locale);
-        infinity = icuSymbols.getInfinity();
-        NaN = icuSymbols.getNaN();
+        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$
         this.locale = locale;
-        currencySymbol = icuSymbols.getCurrencySymbol();
-        intlCurrencySymbol = icuSymbols.getInternationalCurrencySymbol();
-        if (locale.getCountry().length() == 0) {
-            currency = Currency.getInstance("XXX");
-        } else {
+        try {
             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();
     }
 
     /**
@@ -103,6 +92,7 @@
     public Object clone() {
         try {
             DecimalFormatSymbols symbols = (DecimalFormatSymbols) super.clone();
+            symbols.patternChars = patternChars.clone();
             return symbols;
         } catch (CloneNotSupportedException e) {
             return null;
@@ -130,15 +120,8 @@
             return false;
         }
         DecimalFormatSymbols obj = (DecimalFormatSymbols) object;
-        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)
+        return Arrays.equals(patternChars, obj.patternChars)
+                && infinity.equals(obj.infinity) && NaN.equals(obj.NaN)
                 && currencySymbol.equals(obj.currencySymbol)
                 && intlCurrencySymbol.equals(obj.intlCurrencySymbol);
     }
@@ -151,8 +134,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)
@@ -185,7 +168,7 @@
      * @return a char
      */
     public char getDecimalSeparator() {
-        return decimalSeparator;
+        return patternChars[DecimalSeparator];
     }
 
     /**
@@ -195,7 +178,7 @@
      * @return a char
      */
     public char getDigit() {
-        return digit;
+        return patternChars[Digit];
     }
 
     /**
@@ -204,7 +187,7 @@
      * @return a char
      */
     public char getGroupingSeparator() {
-        return groupingSeparator;
+        return patternChars[GroupingSeparator];
     }
 
     /**
@@ -218,8 +201,7 @@
 
     String getLocalPatternChars() {
         // Don't include the MonetaryDecimalSeparator or the MinusSign
-        return new String(new char[]{zeroDigit, digit, decimalSeparator, groupingSeparator,
-                patternSeparator, percent, perMill, exponential});
+        return new String(patternChars, 0, patternChars.length - 2);
     }
 
     /**
@@ -228,7 +210,7 @@
      * @return a char
      */
     public char getMinusSign() {
-        return minusSign;
+        return patternChars[MinusSign];
     }
 
     /**
@@ -238,7 +220,7 @@
      * @return a char
      */
     public char getMonetaryDecimalSeparator() {
-        return monetarySeparator;
+        return patternChars[MonetaryDecimalSeparator];
     }
 
     /**
@@ -257,7 +239,7 @@
      * @return a char
      */
     public char getPatternSeparator() {
-        return patternSeparator;
+        return patternChars[PatternSeparator];
     }
 
     /**
@@ -266,7 +248,7 @@
      * @return a char
      */
     public char getPercent() {
-        return percent;
+        return patternChars[Percent];
     }
 
     /**
@@ -275,7 +257,7 @@
      * @return a char
      */
     public char getPerMill() {
-        return perMill;
+        return patternChars[PerMill];
     }
 
     /**
@@ -284,11 +266,11 @@
      * @return a char
      */
     public char getZeroDigit() {
-        return zeroDigit;
+        return patternChars[ZeroDigit];
     }
 
     char getExponential() {
-        return exponential;
+        return patternChars[Exponent];
     }
 
     /**
@@ -301,12 +283,9 @@
      */
     @Override
     public int 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();
+        return new String(patternChars).hashCode() + infinity.hashCode()
+                + NaN.hashCode() + currencySymbol.hashCode()
+                + intlCurrencySymbol.hashCode();
     }
 
     /**
@@ -382,7 +361,7 @@
      *            the decimal separator character
      */
     public void setDecimalSeparator(char value) {
-        decimalSeparator = value;
+        patternChars[DecimalSeparator] = value;
     }
 
     /**
@@ -392,7 +371,7 @@
      *            the digit character
      */
     public void setDigit(char value) {
-        digit = value;
+        patternChars[Digit] = value;
     }
 
     /**
@@ -402,7 +381,7 @@
      *            the grouping separator character
      */
     public void setGroupingSeparator(char value) {
-        groupingSeparator = value;
+        patternChars[GroupingSeparator] = value;
     }
 
     /**
@@ -422,7 +401,7 @@
      *            the minus sign character
      */
     public void setMinusSign(char value) {
-        minusSign = value;
+        patternChars[MinusSign] = value;
     }
 
     /**
@@ -433,7 +412,7 @@
      *            the monetary decimal separator character
      */
     public void setMonetaryDecimalSeparator(char value) {
-        monetarySeparator = value;
+        patternChars[MonetaryDecimalSeparator] = value;
     }
 
     /**
@@ -454,7 +433,7 @@
      *            the pattern separator character
      */
     public void setPatternSeparator(char value) {
-        patternSeparator = value;
+        patternChars[PatternSeparator] = value;
     }
 
     /**
@@ -464,7 +443,7 @@
      *            the percent character
      */
     public void setPercent(char value) {
-        percent = value;
+        patternChars[Percent] = value;
     }
 
     /**
@@ -474,7 +453,7 @@
      *            the mille percent character
      */
     public void setPerMill(char value) {
-        perMill = value;
+        patternChars[PerMill] = value;
     }
 
     /**
@@ -484,16 +463,56 @@
      *            the zero digit character
      */
     public void setZeroDigit(char value) {
-        zeroDigit = value;
+        patternChars[ZeroDigit] = value;
     }
 
     void setExponential(char value) {
-        exponential = 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();
     }
 
     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$
@@ -520,9 +539,5 @@
         } 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=596044&r1=596043&r2=596044&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 Sat Nov 17 19:24:06 2007
@@ -20,6 +20,8 @@
 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;
 
@@ -54,6 +56,17 @@
         }
     }
 
+    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)) {
@@ -176,32 +189,6 @@
      * @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=596044&r1=596043&r2=596044&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 Sat Nov 17 19:24:06 2007
@@ -24,6 +24,7 @@
 import java.io.ObjectStreamField;
 import java.util.Currency;
 import java.util.Locale;
+import java.util.ResourceBundle;
 
 import org.apache.harmony.text.internal.nls.Messages;
 
@@ -229,10 +230,7 @@
      * @return a NumberFormat
      */
     public static NumberFormat getCurrencyInstance(Locale locale) {
-        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));
+        return getInstance(locale, "Currency"); //$NON-NLS-1$
     }
 
     /**
@@ -254,13 +252,9 @@
      * @return a NumberFormat
      */
     public static NumberFormat getIntegerInstance(Locale locale) {
-        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));
+        NumberFormat format = getInstance(locale, "Integer"); //$NON-NLS-1$
         format.setParseIntegerOnly(true);
         return format;
-        
     }
 
     /**
@@ -285,6 +279,11 @@
         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,
@@ -346,10 +345,12 @@
      * @return a NumberFormat
      */
     public static NumberFormat getNumberInstance(Locale locale) {
-        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));
+        return getInstance(locale, "Number"); //$NON-NLS-1$
+    }
+
+    static String getPattern(Locale locale, String type) {
+        ResourceBundle bundle = getBundle(locale);
+        return bundle.getString(type);
     }
 
     /**
@@ -371,10 +372,7 @@
      * @return a NumberFormat
      */
     public static NumberFormat getPercentInstance(Locale locale) {
-        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));
+        return getInstance(locale, "Percent"); //$NON-NLS-1$
     }
 
     /**



Mime
View raw message