harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ghar...@apache.org
Subject svn commit: r404992 - in /incubator/harmony/enhanced/classlib/trunk/modules/text/src: main/java/java/text/DecimalFormat.java test/java/org/apache/harmony/text/tests/java/text/DecimalFormatTest.java test/resources/serialization/java/text/DecimalFormat.ser
Date Mon, 08 May 2006 09:59:28 GMT
Author: gharley
Date: Mon May  8 02:59:27 2006
New Revision: 404992

URL: http://svn.apache.org/viewcvs?rev=404992&view=rev
Log:
HARMONY-346 : java.text.DecimalFormat serialization is to be implemented

Added:
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/resources/serialization/java/text/DecimalFormat.ser   (with props)
Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/DecimalFormat.java
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/DecimalFormatTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/DecimalFormat.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/DecimalFormat.java?rev=404992&r1=404991&r2=404992&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/DecimalFormat.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/DecimalFormat.java Mon May  8 02:59:27 2006
@@ -16,15 +16,17 @@
 package java.text;
 
 import java.io.IOException;
+import java.io.InvalidObjectException;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
+import java.io.ObjectStreamField;
 import java.math.BigDecimal;
 import java.math.BigInteger;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 import java.util.Currency;
 import java.util.Locale;
 
-import org.apache.harmony.luni.util.NotYetImplementedException;
-
 /**
  * DecimalFormat is used to format and parse numbers, both integers and
  * fractions, based on a pattern. The pattern characters used can be either
@@ -32,24 +34,26 @@
  */
 public class DecimalFormat extends NumberFormat {
 
-    static final long serialVersionUID = 864413376551465018L;
+    private static final long serialVersionUID = 864413376551465018L;
 
-    private boolean parseBigDecimal = false;
+    private transient boolean parseBigDecimal = false;
 
-    private DecimalFormatSymbols symbols;
+    private transient DecimalFormatSymbols symbols;
 
     private transient com.ibm.icu.text.DecimalFormat dform;
 
     private transient com.ibm.icu.text.DecimalFormatSymbols icuSymbols;
 
-    static final int currentSerialVersion = 3;
+    private static final int CURRENT_SERIAL_VERTION = 3;
+
+    private transient int serialVersionOnStream = 3;
 
     /**
      * Constructs a new DecimalFormat for formatting and parsing numbers for the
      * default Locale.
      */
     public DecimalFormat() {
-        this(getPattern(Locale.getDefault(), "Number"));
+        this(getPattern(Locale.getDefault(), "Number")); //$NON-NLS-1$
     }
 
     /**
@@ -80,38 +84,15 @@
      */
     public DecimalFormat(String pattern, DecimalFormatSymbols value) {
         symbols = value;
-        icuSymbols = adapt2ICU(symbols);
-        dform = new com.ibm.icu.text.DecimalFormat(pattern, icuSymbols);
-        setMaximumFractionDigits(dform.getMaximumFractionDigits());
-        setMinimumFractionDigits(dform.getMinimumFractionDigits());
-        setMaximumIntegerDigits(dform.getMaximumIntegerDigits());
-        setMinimumIntegerDigits(dform.getMinimumIntegerDigits());
+        Locale locale = (Locale) this.getInternalField("locale", symbols); //$NON-NLS-1$
+        icuSymbols = new com.ibm.icu.text.DecimalFormatSymbols(locale);
 
-    }
-
-    private com.ibm.icu.text.DecimalFormatSymbols adapt2ICU(
-            DecimalFormatSymbols symbols) {
-        com.ibm.icu.text.DecimalFormatSymbols icuSymbols = new com.ibm.icu.text.DecimalFormatSymbols();
-        String currencyCode = symbols.getCurrency().getCurrencyCode();
-        icuSymbols.setCurrency(com.ibm.icu.util.Currency
-                .getInstance(currencyCode));
-        icuSymbols.setCurrencySymbol(symbols.getCurrencySymbol());
-        icuSymbols.setDecimalSeparator(symbols.getDecimalSeparator());
-        icuSymbols.setDigit(symbols.getDigit());
-        icuSymbols.setGroupingSeparator(symbols.getGroupingSeparator());
-        icuSymbols.setInfinity(symbols.getInfinity());
-        icuSymbols.setInternationalCurrencySymbol(symbols
-                .getInternationalCurrencySymbol());
-        icuSymbols.setMinusSign(symbols.getMinusSign());
-        icuSymbols.setMonetaryDecimalSeparator(symbols
-                .getMonetaryDecimalSeparator());
-        icuSymbols.setNaN(symbols.getNaN());
-        icuSymbols.setPatternSeparator(symbols.getPatternSeparator());
-        icuSymbols.setPercent(symbols.getPercent());
-        icuSymbols.setPerMill(symbols.getPerMill());
-        icuSymbols.setZeroDigit(symbols.getZeroDigit());
+        dform = new com.ibm.icu.text.DecimalFormat(pattern, icuSymbols);
 
-        return icuSymbols;
+        super.setMaximumFractionDigits(dform.getMaximumFractionDigits());
+        super.setMaximumIntegerDigits(dform.getMaximumIntegerDigits());
+        super.setMinimumFractionDigits(dform.getMinimumFractionDigits());
+        super.setMinimumIntegerDigits(dform.getMinimumIntegerDigits());
     }
 
     /**
@@ -237,6 +218,22 @@
         return dform.format(value, buffer, position);
     }
 
+    /**
+     * Formats the number into the specified StringBuffer using the pattern of
+     * this DecimalFormat. If the field specified by the FieldPosition is
+     * formatted, set the begin and end index of the formatted field in the
+     * FieldPosition.
+     * 
+     * @param number
+     *            the object to format
+     * @param toAppandTo
+     *            the StringBuffer
+     * @param pos
+     *            the FieldPosition
+     * @return the StringBuffer parameter <code>buffer</code>
+     * @throws IllegalArgumentException
+     *             if the given number is not instance of <code>Number</code>
+     */
     public final StringBuffer format(Object number, StringBuffer toAppendTo,
             FieldPosition pos) {
         if (!(number instanceof Number)) {
@@ -268,6 +265,9 @@
      * @see DecimalFormatSymbols#getCurrency()
      */
     public Currency getCurrency() {
+        if (dform.getCurrency() == null) {
+            return null;
+        }
         return Currency.getInstance(dform.getCurrency().getCurrencyCode());
     }
 
@@ -360,10 +360,31 @@
         return this.parseBigDecimal;
     }
 
+    /**
+     * When DecimalFormat is used to parsing, and this value is set to true,
+     * then all the resulting number will be of type
+     * <code>java.lang.Integer</code>. Except that, NaN, positive and
+     * negative infinity are still returned as <code>java.lang.Double</code>
+     * 
+     * In this implementation, com.ibm.icu.text.DecimalFormat is wrapped to
+     * fulfill most of the format and parse feature. And this method is
+     * delegated to the wrapped instance of com.ibm.icu.text.DecimalFormat.
+     * 
+     * @param value
+     *            If set to true, all the resulting number will be of type
+     *            java.lang.Integer except some special cases.
+     */
     public void setParseIntegerOnly(boolean value) {
         dform.setParseIntegerOnly(value);
     }
 
+    /**
+     * Returns true if this <code>DecimalFormat</code>'s all resulting number
+     * will be of type <code>java.lang.Integer</code>
+     * 
+     * @return true if this <code>DecimalFormat</code>'s all resulting number
+     *         will be of type <code>java.lang.Integer</code>
+     */
     public boolean isParseIntegerOnly() {
         return dform.isParseIntegerOnly();
     }
@@ -431,7 +452,8 @@
      */
     public void setDecimalFormatSymbols(DecimalFormatSymbols value) {
         symbols = (DecimalFormatSymbols) value.clone();
-        icuSymbols = adapt2ICU(symbols);
+        Locale locale = (Locale) this.getInternalField("locale", symbols); //$NON-NLS-1$
+        icuSymbols = new com.ibm.icu.text.DecimalFormatSymbols(locale);
         dform.setDecimalFormatSymbols(icuSymbols);
     }
 
@@ -469,18 +491,23 @@
     public void setGroupingSize(int value) {
         dform.setGroupingSize(value);
     }
-    
-    /*
-     * (non-Javadoc)
-     * @see java.text.NumberFormat#setGroupingUsed(boolean)
+
+    /**
+     * Sets whether or not grouping will be used in this format. Grouping
+     * affects both parsing and formatting.
+     * 
+     * @param value
+     *            true if uses grouping,false otherwise.
+     * 
      */
     public void setGroupingUsed(boolean value) {
         dform.setGroupingUsed(value);
     }
 
-    /*
-     * (non-Javadoc)
-     * @see java.text.NumberFormat#setGroupingUsed(boolean)
+    /**
+     * This value indicates whether grouping will be used in this format.
+     * 
+     * @return true if grouping is used,false otherwise.
      */
     public boolean isGroupingUsed() {
         return dform.isGroupingUsed();
@@ -592,6 +619,9 @@
     /**
      * Let users change the behavior of a DecimalFormat, If set to true all the
      * returned objects will be of type BigDecimal
+     * 
+     * @param newValue
+     *            true if all the returned objects should be type of BigDecimal
      */
     public void setParseBigDecimal(boolean newValue) {
         this.parseBigDecimal = newValue;
@@ -617,14 +647,212 @@
         return dform.toPattern();
     }
 
+    // the fields list to be serialized
+    private static final ObjectStreamField[] serialPersistentFields = {
+            new ObjectStreamField("positivePrefix", String.class), //$NON-NLS-1$
+            new ObjectStreamField("positiveSuffix", String.class), //$NON-NLS-1$
+            new ObjectStreamField("negativePrefix", String.class), //$NON-NLS-1$
+            new ObjectStreamField("negativeSuffix", String.class), //$NON-NLS-1$
+            new ObjectStreamField("posPrefixPattern", String.class), //$NON-NLS-1$
+            new ObjectStreamField("posSuffixPattern", String.class), //$NON-NLS-1$
+            new ObjectStreamField("negPrefixPattern", String.class), //$NON-NLS-1$
+            new ObjectStreamField("negSuffixPattern", String.class), //$NON-NLS-1$
+            new ObjectStreamField("multiplier", int.class), //$NON-NLS-1$
+            new ObjectStreamField("groupingSize", byte.class), //$NON-NLS-1$
+            new ObjectStreamField("decimalSeparatorAlwaysShown", boolean.class), //$NON-NLS-1$
+            new ObjectStreamField("parseBigDecimal", boolean.class), //$NON-NLS-1$
+            new ObjectStreamField("symbols", DecimalFormatSymbols.class), //$NON-NLS-1$
+            new ObjectStreamField("useExponentialNotation", boolean.class), //$NON-NLS-1$
+            new ObjectStreamField("minExponentDigits", byte.class), //$NON-NLS-1$
+            new ObjectStreamField("maximumIntegerDigits", int.class), //$NON-NLS-1$
+            new ObjectStreamField("minimumIntegerDigits", int.class), //$NON-NLS-1$
+            new ObjectStreamField("maximumFractionDigits", int.class), //$NON-NLS-1$
+            new ObjectStreamField("minimumFractionDigits", int.class), //$NON-NLS-1$
+            new ObjectStreamField("serialVersionOnStream", int.class), }; //$NON-NLS-1$
+
+    /**
+     * Writes serialized fields following serialized forms specified by Java specification. 
+     * 
+     * @param stream
+     *              the output stream to write serialized bytes
+     * @throws IOException
+     *              if some I/O error occurs
+     * @throws ClassNotFoundException
+     */
     private void writeObject(ObjectOutputStream stream) throws IOException,
             ClassNotFoundException {
-        throw new NotYetImplementedException();
+        ObjectOutputStream.PutField fields = stream.putFields();
+        fields.put("positivePrefix", dform.getPositivePrefix()); //$NON-NLS-1$
+        fields.put("positiveSuffix", dform.getPositiveSuffix()); //$NON-NLS-1$
+        fields.put("negativePrefix", dform.getNegativePrefix()); //$NON-NLS-1$
+        fields.put("negativeSuffix", dform.getNegativeSuffix()); //$NON-NLS-1$
+        String posPrefixPattern = (String) this.getInternalField(
+                "posPrefixPattern", dform); //$NON-NLS-1$
+        fields.put("posPrefixPattern", posPrefixPattern); //$NON-NLS-1$
+        String posSuffixPattern = (String) this.getInternalField(
+                "posSuffixPattern", dform); //$NON-NLS-1$
+        fields.put("posSuffixPattern", posSuffixPattern); //$NON-NLS-1$
+        String negPrefixPattern = (String) this.getInternalField(
+                "negPrefixPattern", dform); //$NON-NLS-1$
+        fields.put("negPrefixPattern", negPrefixPattern); //$NON-NLS-1$
+        String negSuffixPattern = (String) this.getInternalField(
+                "negSuffixPattern", dform); //$NON-NLS-1$
+        fields.put("negSuffixPattern", negSuffixPattern); //$NON-NLS-1$
+        fields.put("multiplier", dform.getMultiplier()); //$NON-NLS-1$
+        fields.put("groupingSize", (byte) dform.getGroupingSize()); //$NON-NLS-1$
+        fields.put("decimalSeparatorAlwaysShown", dform //$NON-NLS-1$
+                .isDecimalSeparatorAlwaysShown());
+        fields.put("parseBigDecimal", parseBigDecimal); //$NON-NLS-1$
+        fields.put("symbols", symbols); //$NON-NLS-1$
+        boolean useExponentialNotation = ((Boolean) this.getInternalField(
+                "useExponentialNotation", dform)).booleanValue(); //$NON-NLS-1$
+        fields.put("useExponentialNotation", useExponentialNotation); //$NON-NLS-1$
+        byte minExponentDigits = ((Byte) this.getInternalField(
+                "minExponentDigits", dform)).byteValue(); //$NON-NLS-1$
+        fields.put("minExponentDigits", minExponentDigits); //$NON-NLS-1$
+        fields.put("maximumIntegerDigits", dform.getMaximumIntegerDigits()); //$NON-NLS-1$
+        fields.put("minimumIntegerDigits", dform.getMinimumIntegerDigits()); //$NON-NLS-1$
+        fields.put("maximumFractionDigits", dform.getMaximumFractionDigits()); //$NON-NLS-1$
+        fields.put("minimumFractionDigits", dform.getMinimumFractionDigits()); //$NON-NLS-1$
+        fields.put("serialVersionOnStream", CURRENT_SERIAL_VERTION); //$NON-NLS-1$
+        stream.writeFields();
+
     }
 
+    /**
+     * Reads serialized fields following serialized forms specified by Java specification.
+     * 
+     * @param stream
+     *              the input stream to read serialized bytes
+     * @throws IOException
+     *              if some I/O error occurs
+     * @throws ClassNotFoundException
+     *              if some class of serilized objects or fields cannot be found
+     */
     private void readObject(ObjectInputStream stream) throws IOException,
             ClassNotFoundException {
-        throw new NotYetImplementedException();
+
+        ObjectInputStream.GetField fields = stream.readFields();
+        String positivePrefix = (String) fields.get("positivePrefix", ""); //$NON-NLS-1$ //$NON-NLS-2$
+        String positiveSuffix = (String) fields.get("positiveSuffix", ""); //$NON-NLS-1$ //$NON-NLS-2$
+        String negativePrefix = (String) fields.get("negativePrefix", "-"); //$NON-NLS-1$ //$NON-NLS-2$
+        String negativeSuffix = (String) fields.get("negativeSuffix", ""); //$NON-NLS-1$ //$NON-NLS-2$
+
+        String posPrefixPattern = (String) fields.get("posPrefixPattern", ""); //$NON-NLS-1$ //$NON-NLS-2$
+        String posSuffixPattern = (String) fields.get("posSuffixPattern", ""); //$NON-NLS-1$ //$NON-NLS-2$
+        String negPrefixPattern = (String) fields.get("negPrefixPattern", "-"); //$NON-NLS-1$ //$NON-NLS-2$
+        String negSuffixPattern = (String) fields.get("negSuffixPattern", ""); //$NON-NLS-1$ //$NON-NLS-2$
+
+        int multiplier = fields.get("multiplier", 1); //$NON-NLS-1$
+        byte groupingSize = fields.get("groupingSize", (byte) 3); //$NON-NLS-1$
+        boolean decimalSeparatorAlwaysShown = fields.get(
+                "decimalSeparatorAlwaysShown", false); //$NON-NLS-1$
+        boolean parseBigDecimal = fields.get("parseBigDecimal", false); //$NON-NLS-1$
+        symbols = (DecimalFormatSymbols) fields.get("symbols", null); //$NON-NLS-1$
+
+        boolean useExponentialNotation = fields.get("useExponentialNotation", //$NON-NLS-1$
+                false);
+        byte minExponentDigits = fields.get("minExponentDigits", (byte) 0); //$NON-NLS-1$
+
+        int maximumIntegerDigits = fields.get("maximumIntegerDigits", 309); //$NON-NLS-1$
+        int minimumIntegerDigits = fields.get("minimumIntegerDigits", 309); //$NON-NLS-1$
+        int maximumFractionDigits = fields.get("maximumFractionDigits", 340); //$NON-NLS-1$
+        int minimumFractionDigits = fields.get("minimumFractionDigits", 340); //$NON-NLS-1$
+        this.serialVersionOnStream = fields.get("serialVersionOnStream", 0); //$NON-NLS-1$
+
+        Locale locale = (Locale) getInternalField("locale", symbols); //$NON-NLS-1$
+        dform = new com.ibm.icu.text.DecimalFormat("", // pattern,
+                // //$NON-NLS-1$
+                new com.ibm.icu.text.DecimalFormatSymbols(locale));
+        setInternalField("useExponentialNotation", dform, new Boolean( //$NON-NLS-1$
+                useExponentialNotation));
+        setInternalField("minExponentDigits", dform, //$NON-NLS-1$
+                new Byte(minExponentDigits));
+        dform.setPositivePrefix(positivePrefix);
+        dform.setPositiveSuffix(positiveSuffix);
+        dform.setNegativePrefix(negativePrefix);
+        dform.setNegativeSuffix(negativeSuffix);
+        setInternalField("posPrefixPattern", dform, posPrefixPattern); //$NON-NLS-1$
+        setInternalField("posSuffixPattern", dform, posSuffixPattern); //$NON-NLS-1$
+        setInternalField("negPrefixPattern", dform, negPrefixPattern); //$NON-NLS-1$
+        setInternalField("negSuffixPattern", dform, negSuffixPattern); //$NON-NLS-1$
+        dform.setMultiplier(multiplier);
+        dform.setGroupingSize(groupingSize);
+        dform.setDecimalSeparatorAlwaysShown(decimalSeparatorAlwaysShown);
+        dform.setMinimumIntegerDigits(minimumIntegerDigits);
+        dform.setMaximumIntegerDigits(maximumIntegerDigits);
+        dform.setMinimumFractionDigits(minimumFractionDigits);
+        dform.setMaximumFractionDigits(maximumFractionDigits);
+        this.setParseBigDecimal(parseBigDecimal);
+
+        if (super.getMaximumIntegerDigits() > Integer.MAX_VALUE
+                || super.getMinimumIntegerDigits() > Integer.MAX_VALUE
+                || super.getMaximumFractionDigits() > Integer.MAX_VALUE
+                || super.getMinimumIntegerDigits() > Integer.MAX_VALUE) {
+            throw new InvalidObjectException("The deserialized date is invalid"); //$NON-NLS-1$
+        }
+        if (serialVersionOnStream < 3) {
+            setMaximumIntegerDigits(super.getMinimumIntegerDigits());
+            setMinimumIntegerDigits(super.getMinimumIntegerDigits());
+            setMaximumFractionDigits(super.getMaximumFractionDigits());
+            setMinimumFractionDigits(super.getMinimumFractionDigits());
+        }
+        if (serialVersionOnStream < 1) {
+            this.setInternalField("useExponentialNotation", dform, //$NON-NLS-1$
+                    Boolean.FALSE);
+        }
+        serialVersionOnStream = 3;
+    }
+
+    /*
+     * Sets private field value by reflection.
+     * 
+     * @param fieldName the field name to be set @param target the object which
+     * field to be set @param value the value to be set
+     */
+    private void setInternalField(final String fieldName, final Object target,
+            final Object value) {
+        AccessController
+                .doPrivileged(new PrivilegedAction<java.lang.reflect.Field>() {
+                    public java.lang.reflect.Field run() {
+                        java.lang.reflect.Field field = null;
+                        try {
+                            field = target.getClass().getDeclaredField(
+                                    fieldName);
+                            field.setAccessible(true);
+                            field.set(target, value);
+                        } catch (Exception e) {
+                            return null;
+                        }
+                        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: incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/DecimalFormatTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/DecimalFormatTest.java?rev=404992&r1=404991&r2=404992&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/DecimalFormatTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/DecimalFormatTest.java Mon May  8 02:59:27 2006
@@ -15,6 +15,7 @@
 
 package org.apache.harmony.text.tests.java.text;
 
+import java.io.ObjectInputStream;
 import java.math.BigDecimal;
 import java.math.BigInteger;
 import java.text.DecimalFormat;
@@ -25,10 +26,10 @@
 import java.util.Currency;
 import java.util.Locale;
 
+import junit.framework.TestCase;
 import tests.support.Support_BitSet;
 import tests.support.Support_DecimalFormat;
-
-import junit.framework.TestCase;
+import tests.util.SerializationTester;
 
 public class DecimalFormatTest extends TestCase {
 
@@ -39,7 +40,7 @@
     public void test_isParseBigDecimalLjava_lang_Boolean_isParseIntegerOnlyLjava_lang_Boolean() {
 
         // parseBigDecimal default to false
-        DecimalFormat form = (DecimalFormat) DecimalFormat.getInstance();
+        DecimalFormat form = (DecimalFormat) DecimalFormat.getInstance(Locale.US);
         assertFalse(form.isParseBigDecimal());
         form.setParseBigDecimal(true);
         assertTrue(form.isParseBigDecimal());
@@ -53,7 +54,7 @@
     // Test the type of the returned object
 
     public void test_parseLjava_lang_String_Ljava_text_ParsePosition() {
-        DecimalFormat form = (DecimalFormat) DecimalFormat.getInstance();
+        DecimalFormat form = (DecimalFormat) DecimalFormat.getInstance(Locale.US);
         Number number = form.parse("23.1", new ParsePosition(0));
         assertTrue(number instanceof Double);
 
@@ -75,7 +76,7 @@
         // With the exception that, the value is out of the bound of Long or
         // some special values such as NaN or Infinity.
 
-        form = (DecimalFormat) DecimalFormat.getInstance();
+        form = (DecimalFormat) DecimalFormat.getInstance(Locale.US);
         form.setParseIntegerOnly(true);
         number = form.parse("23.1f", new ParsePosition(0));
 
@@ -94,7 +95,7 @@
 
         // Even if parseIntegerOnly is set to true, NaN will be parsed to Double
 
-        form = (DecimalFormat) DecimalFormat.getInstance();
+        form = (DecimalFormat) DecimalFormat.getInstance(Locale.US);
         form.setParseIntegerOnly(true);
         DecimalFormatSymbols symbols = new DecimalFormatSymbols();
         number = form.parse(symbols.getNaN(), new ParsePosition(0));
@@ -103,7 +104,7 @@
         // Even if parseIntegerOnly is set to true, Infinity will still be
         // parsed to Double
 
-        form = (DecimalFormat) DecimalFormat.getInstance();
+        form = (DecimalFormat) DecimalFormat.getInstance(Locale.US);
         form.setParseIntegerOnly(true);
         symbols = new DecimalFormatSymbols();
         number = form.parse(symbols.getInfinity(), new ParsePosition(0));
@@ -111,7 +112,7 @@
 
         // ParseBigDecimal take precedence of parseBigInteger
 
-        form = (DecimalFormat) DecimalFormat.getInstance();
+        form = (DecimalFormat) DecimalFormat.getInstance(Locale.US);
         form.setParseIntegerOnly(true);
         form.setParseBigDecimal(true);
 
@@ -130,7 +131,7 @@
         // Test whether the parsed object is of type float. (To be specific,
         // they are of type Double)
 
-        form = (DecimalFormat) DecimalFormat.getInstance();
+        form = (DecimalFormat) DecimalFormat.getInstance(Locale.US);
 
         number = form.parse("23.1f", new ParsePosition(0));
         assertTrue(number instanceof Double);
@@ -142,7 +143,7 @@
 
         // Integer will be parsed to Long, unless parseBigDecimal is set to true
 
-        form = (DecimalFormat) DecimalFormat.getInstance();
+        form = (DecimalFormat) DecimalFormat.getInstance(Locale.US);
 
         number = form.parse("123", new ParsePosition(0));
         assertTrue(number instanceof Long);
@@ -154,7 +155,7 @@
 
         // NaN will be parsed to Double, no matter parseBigDecimal set or not.
 
-        form = (DecimalFormat) DecimalFormat.getInstance();
+        form = (DecimalFormat) DecimalFormat.getInstance(Locale.US);
         symbols = new DecimalFormatSymbols();
         number = form.parse(symbols.getNaN() + "", new ParsePosition(0));
         assertTrue(number instanceof Double);
@@ -166,7 +167,7 @@
         // Infinity will be parsed to Double, no matter parseBigDecimal set or
         // not.
 
-        form = (DecimalFormat) DecimalFormat.getInstance();
+        form = (DecimalFormat) DecimalFormat.getInstance(Locale.US);
         symbols = new DecimalFormatSymbols();
 
         number = form.parse(symbols.getInfinity(), new ParsePosition(0));
@@ -175,7 +176,7 @@
         assertEquals("Infinity", number.toString());
         // When set bigDecimal to true, the result of parsing infinity
 
-        form = (DecimalFormat) DecimalFormat.getInstance();
+        form = (DecimalFormat) DecimalFormat.getInstance(Locale.US);
         symbols = new DecimalFormatSymbols();
         form.setParseBigDecimal(true);
 
@@ -186,7 +187,7 @@
         // Negative infinity will be parsed to double no matter parseBigDecimal
         // set or not
 
-        form = (DecimalFormat) DecimalFormat.getInstance();
+        form = (DecimalFormat) DecimalFormat.getInstance(Locale.US);
         symbols = new DecimalFormatSymbols();
 
         number = form.parse("-" + symbols.getInfinity(), new ParsePosition(0));
@@ -196,7 +197,7 @@
 
         // When set bigDecimal to true, the result of parsing minus infinity
 
-        form = (DecimalFormat) DecimalFormat.getInstance();
+        form = (DecimalFormat) DecimalFormat.getInstance(Locale.US);
         symbols = new DecimalFormatSymbols();
         form.setParseBigDecimal(true);
 
@@ -208,7 +209,7 @@
         // -0.0 will be parsed to different type according to the combination of
         // parseBigDecimal and parseIntegerOnly
 
-        form = (DecimalFormat) DecimalFormat.getInstance();
+        form = (DecimalFormat) DecimalFormat.getInstance(Locale.US);
 
         // parseBigDecimal == true;
         // parseIntegerOnly == false;
@@ -257,7 +258,7 @@
         // When parseBigDecimal is set to false, no matter how massive the
         // mantissa part of a number is, the number will be parsed into Double
 
-        form = (DecimalFormat) DecimalFormat.getInstance();
+        form = (DecimalFormat) DecimalFormat.getInstance(Locale.US);
 
         number = form.parse("9,223,372,036,854,775,808.00",
                 new ParsePosition(0));
@@ -273,7 +274,7 @@
         // When parseBigDecimal is set to true, if mantissa part of number
         // exceeds Long.MAX_VALUE, the number will be parsed into BigDecimal
 
-        form = (DecimalFormat) DecimalFormat.getInstance();
+        form = (DecimalFormat) DecimalFormat.getInstance(Locale.US);
 
         form.setParseBigDecimal(true);
         number = form.parse("9,223,372,036,854,775,808.00",
@@ -320,7 +321,7 @@
     }
 
     public void test_getMaximumFractionDigits() {
-        NumberFormat nform = DecimalFormat.getInstance();
+        NumberFormat nform = DecimalFormat.getInstance(Locale.US);
         DecimalFormat form = (DecimalFormat) nform;
 
         // getMaximumFractionDigits of NumberFormat default to 3
@@ -344,7 +345,7 @@
     }
 
     public void test_getMinimumFractionDigits() {
-        NumberFormat nform = DecimalFormat.getInstance();
+        NumberFormat nform = DecimalFormat.getInstance(Locale.US);
         DecimalFormat form = (DecimalFormat) nform;
 
         // getMinimumFractionDigits from NumberFormat (default to 0)
@@ -371,7 +372,7 @@
         DecimalFormat form = new DecimalFormat("00.###E0");
         assertEquals(2, form.getMaximumIntegerDigits());
 
-        NumberFormat nform = DecimalFormat.getInstance();
+        NumberFormat nform = DecimalFormat.getInstance(Locale.US);
         form = null;
         if (nform instanceof DecimalFormat) {
             form = (DecimalFormat) nform;
@@ -393,7 +394,7 @@
         assertEquals(500, nform.getMaximumIntegerDigits());
         assertEquals(500, form.getMaximumIntegerDigits());
 
-        nform = DecimalFormat.getInstance();
+        nform = DecimalFormat.getInstance(Locale.US);
         form = null;
         if (nform instanceof DecimalFormat) {
             form = (DecimalFormat) nform;
@@ -411,7 +412,7 @@
 
     public void test_getMinimumIntegerDigits() {
         final int minIntDigit = 1;
-        NumberFormat nform = DecimalFormat.getInstance();
+        NumberFormat nform = DecimalFormat.getInstance(Locale.US);
         DecimalFormat form = (DecimalFormat) nform;
 
         // getMaximumIntegerDigits from NumberFormat (default to 1)
@@ -432,7 +433,7 @@
     }
 
     public void test_formatLjava_lang_Obj_Ljava_StringBuffer_Ljava_text_FieldPosition() {
-        NumberFormat nform = DecimalFormat.getInstance();
+        NumberFormat nform = DecimalFormat.getInstance(Locale.US);
         DecimalFormat form = (DecimalFormat) nform;
 
         // If Object(including null) is not of type Nubmer,
@@ -587,7 +588,7 @@
     }
 
     public void test_setMaximumFractionDigitsLjava_lang_Integer() {
-        NumberFormat nform = DecimalFormat.getInstance();
+        NumberFormat nform = DecimalFormat.getInstance(Locale.US);
         DecimalFormat form = (DecimalFormat) nform;
 
         form.setMaximumFractionDigits(-2);
@@ -598,7 +599,7 @@
     }
 
     public void test_setMinimumFractionDigitsLjava_lang_Integer() {
-        NumberFormat nform = DecimalFormat.getInstance();
+        NumberFormat nform = DecimalFormat.getInstance(Locale.US);
         DecimalFormat form = (DecimalFormat) nform;
 
         form.setMinimumFractionDigits(-3);
@@ -609,7 +610,7 @@
     }
 
     public void test_setMaximumIntegerDigitsLjava_lang_Integer() {
-        NumberFormat nform = DecimalFormat.getInstance();
+        NumberFormat nform = DecimalFormat.getInstance(Locale.US);
         DecimalFormat form = (DecimalFormat) nform;
 
         form.setMaximumIntegerDigits(-3);
@@ -620,7 +621,7 @@
     }
 
     public void test_setMinimumIntegerDigitsLjava_lang_Integer() {
-        NumberFormat nform = DecimalFormat.getInstance();
+        NumberFormat nform = DecimalFormat.getInstance(Locale.US);
         DecimalFormat form = (DecimalFormat) nform;
 
         form.setMinimumIntegerDigits(-3);
@@ -633,7 +634,7 @@
     // When MaxFractionDigits is set first and less than MinFractionDigits, max
     // will be changed to min value
     public void test_setMinimumFactionDigitsLjava_lang_Integer_setMaximumFractionDigitsLjava_lang_Integer() {
-        NumberFormat nform = DecimalFormat.getInstance();
+        NumberFormat nform = DecimalFormat.getInstance(Locale.US);
         DecimalFormat form = (DecimalFormat) nform;
 
         form.setMaximumFractionDigits(100);
@@ -652,7 +653,7 @@
     // When MinFractionDigits is set first and less than MaxFractionDigits, min
     // will be changed to max value
     public void test_setMaximumFactionDigitsLjava_lang_Integer_setMinimumFractionDigitsLjava_lang_Integer() {
-        NumberFormat nform = DecimalFormat.getInstance();
+        NumberFormat nform = DecimalFormat.getInstance(Locale.US);
         DecimalFormat form = (DecimalFormat) nform;
 
         form.setMinimumFractionDigits(200);
@@ -669,12 +670,12 @@
     }
 
     public void test_equalsLjava_lang_Object() {
-        DecimalFormat format = (DecimalFormat) DecimalFormat.getInstance();
+        DecimalFormat format = (DecimalFormat) DecimalFormat.getInstance(Locale.US);
         DecimalFormat cloned = (DecimalFormat) format.clone();
-        cloned.setDecimalFormatSymbols(new DecimalFormatSymbols());
+        cloned.setDecimalFormatSymbols(new DecimalFormatSymbols(Locale.US));
         assertEquals(format, cloned);
 
-        Currency c = Currency.getInstance(Locale.getDefault());
+        Currency c = Currency.getInstance(Locale.US);
         cloned.setCurrency(c);
 
         assertEquals(format, cloned);
@@ -708,7 +709,6 @@
         assertEquals("1970", buf.toString());
         assertFalse(format.isGroupingUsed());
     }
-    
 
     /**
      * @tests java.text.DecimalFormat#DecimalFormat(java.lang.String)
@@ -730,24 +730,24 @@
      */
     public void test_applyPatternLjava_lang_String() {
         DecimalFormat format = new DecimalFormat("#.#");
-		assertEquals("Wrong pattern 1", "#0.#", format.toPattern());
+        assertEquals("Wrong pattern 1", "#0.#", format.toPattern());
         format = new DecimalFormat("#.");
-		assertEquals("Wrong pattern 2", "#0.", format.toPattern());
+        assertEquals("Wrong pattern 2", "#0.", format.toPattern());
         format = new DecimalFormat("#");
-		assertEquals("Wrong pattern 3", "#", format.toPattern());
+        assertEquals("Wrong pattern 3", "#", format.toPattern());
         format = new DecimalFormat(".#");
-		assertEquals("Wrong pattern 4", "#.0", format.toPattern());
+        assertEquals("Wrong pattern 4", "#.0", format.toPattern());
     }
 
     /**
      * @tests java.text.DecimalFormat#clone()
      */
     public void test_clone() {
-        DecimalFormat format = (DecimalFormat) DecimalFormat.getInstance();
+        DecimalFormat format = (DecimalFormat) DecimalFormat.getInstance(Locale.US);
         DecimalFormat cloned = (DecimalFormat) format.clone();
         assertEquals(cloned.getDecimalFormatSymbols(), format
                 .getDecimalFormatSymbols());
-        
+
         format = new DecimalFormat("'$'0000.0000");
         DecimalFormat format1 = (DecimalFormat) (format.clone());
         // make sure the objects are equal
@@ -1011,64 +1011,63 @@
         Support_BitSet failures = new Support_BitSet();
 
         DecimalFormat df = new DecimalFormat("00.0#E0");
-		assertEquals("00.0#E0: 0", "00.0E0", df.format(0));
-		assertEquals("00.0#E0: 1", "10.0E-1", df.format(1));
-		assertEquals("00.0#E0: 12", "12.0E0", df.format(12));
-		assertEquals("00.0#E0: 123", "12.3E1", df.format(123));
-		assertEquals("00.0#E0: 1234", "12.34E2", df.format(1234));
-		assertEquals("00.0#E0: 12346", "12.35E3", df.format(12346));
-		assertEquals("00.0#E0: 99999", "10.0E4", df.format(99999));
-		assertEquals("00.0#E0: -1", "-10.0E-1", df.format(-1));
-		assertEquals("00.0#E0: -12", "-12.0E0", df.format(-12));
-		assertEquals("00.0#E0: -123", "-12.3E1", df.format(-123));
-		assertEquals("00.0#E0: -1234", "-12.34E2", df.format(-1234));
-		assertEquals("00.0#E0: -12346", "-12.35E3", df.format(-12346));
-		assertEquals("00.0#E0: -99999", "-10.0E4", df.format(-99999));
+        assertEquals("00.0#E0: 0", "00.0E0", df.format(0));
+        assertEquals("00.0#E0: 1", "10.0E-1", df.format(1));
+        assertEquals("00.0#E0: 12", "12.0E0", df.format(12));
+        assertEquals("00.0#E0: 123", "12.3E1", df.format(123));
+        assertEquals("00.0#E0: 1234", "12.34E2", df.format(1234));
+        assertEquals("00.0#E0: 12346", "12.35E3", df.format(12346));
+        assertEquals("00.0#E0: 99999", "10.0E4", df.format(99999));
+        assertEquals("00.0#E0: -1", "-10.0E-1", df.format(-1));
+        assertEquals("00.0#E0: -12", "-12.0E0", df.format(-12));
+        assertEquals("00.0#E0: -123", "-12.3E1", df.format(-123));
+        assertEquals("00.0#E0: -1234", "-12.34E2", df.format(-1234));
+        assertEquals("00.0#E0: -12346", "-12.35E3", df.format(-12346));
+        assertEquals("00.0#E0: -99999", "-10.0E4", df.format(-99999));
 
         df = new DecimalFormat("##0.0E0");
-		assertEquals("##0.0E0: 0", "0.0E0", df.format(0));
-		assertEquals("##0.0E0: 1", "1.0E0", df.format(1));
-		assertEquals("##0.0E0: 12", "12E0", df.format(12));
-		assertEquals("##0.0E0: 123", "123E0", df.format(123));
-		assertEquals("##0.0E0: 1234", "1.234E3", df.format(1234));
-		assertEquals("##0.0E0: 12346", "12.35E3", df.format(12346));
+        assertEquals("##0.0E0: 0", "0.0E0", df.format(0));
+        assertEquals("##0.0E0: 1", "1.0E0", df.format(1));
+        assertEquals("##0.0E0: 12", "12E0", df.format(12));
+        assertEquals("##0.0E0: 123", "123E0", df.format(123));
+        assertEquals("##0.0E0: 1234", "1.234E3", df.format(1234));
+        assertEquals("##0.0E0: 12346", "12.35E3", df.format(12346));
         // Fails in JDK 1.2.2
         if (!df.format(99999).equals("100E3"))
             failures.set(failCount);
         failCount++;
-		assertEquals("##0.0E0: 999999", "1.0E6", df.format(999999));
+        assertEquals("##0.0E0: 999999", "1.0E6", df.format(999999));
 
         df = new DecimalFormat("#00.0##E0");
         // Fails in JDK 1.2.2
         if (!df.format(0).equals("0.00E0"))
             failures.set(failCount);
         failCount++;
-		assertEquals("#00.0##E0: 1", "1.00E0", df.format(1));
-		assertEquals("#00.0##E0: 12", "12.0E0", df.format(12));
-		assertEquals("#00.0##E0: 123", "123E0", df.format(123));
-		assertEquals("#00.0##E0: 1234", "1.234E3", df.format(1234));
-		assertEquals("#00.0##E0: 12345", "12.345E3", df.format(12345));
-		assertEquals("#00.0##E0: 123456", "123.456E3", df.format(123456));
-		assertEquals("#00.0##E0: 1234567", "1.23457E6", df.format(1234567));
-		assertEquals("#00.0##E0: 12345678", 
-				"12.3457E6", df.format(12345678));
-		assertEquals("#00.0##E0: 99999999", "100E6", df.format(99999999));
+        assertEquals("#00.0##E0: 1", "1.00E0", df.format(1));
+        assertEquals("#00.0##E0: 12", "12.0E0", df.format(12));
+        assertEquals("#00.0##E0: 123", "123E0", df.format(123));
+        assertEquals("#00.0##E0: 1234", "1.234E3", df.format(1234));
+        assertEquals("#00.0##E0: 12345", "12.345E3", df.format(12345));
+        assertEquals("#00.0##E0: 123456", "123.456E3", df.format(123456));
+        assertEquals("#00.0##E0: 1234567", "1.23457E6", df.format(1234567));
+        assertEquals("#00.0##E0: 12345678", "12.3457E6", df.format(12345678));
+        assertEquals("#00.0##E0: 99999999", "100E6", df.format(99999999));
 
         df = new DecimalFormat("#.0E0");
-		assertEquals("#.0E0: 0", ".0E0", df.format(0));
-		assertEquals("#.0E0: 1", ".1E1", df.format(1));
-		assertEquals("#.0E0: 12", ".12E2", df.format(12));
-		assertEquals("#.0E0: 123", ".12E3", df.format(123));
-		assertEquals("#.0E0: 1234", ".12E4", df.format(1234));
-		assertEquals("#.0E0: 9999", ".1E5", df.format(9999));
+        assertEquals("#.0E0: 0", ".0E0", df.format(0));
+        assertEquals("#.0E0: 1", ".1E1", df.format(1));
+        assertEquals("#.0E0: 12", ".12E2", df.format(12));
+        assertEquals("#.0E0: 123", ".12E3", df.format(123));
+        assertEquals("#.0E0: 1234", ".12E4", df.format(1234));
+        assertEquals("#.0E0: 9999", ".1E5", df.format(9999));
 
         df = new DecimalFormat("0.#E0");
-		assertEquals("0.#E0: 0", "0E0", df.format(0));
-		assertEquals("0.#E0: 1", "1E0", df.format(1));
-		assertEquals("0.#E0: 12", "1.2E1", df.format(12));
-		assertEquals("0.#E0: 123", "1.2E2", df.format(123));
-		assertEquals("0.#E0: 1234", "1.2E3", df.format(1234));
-		assertEquals("0.#E0: 9999", "1E4", df.format(9999));
+        assertEquals("0.#E0: 0", "0E0", df.format(0));
+        assertEquals("0.#E0: 1", "1E0", df.format(1));
+        assertEquals("0.#E0: 12", "1.2E1", df.format(12));
+        assertEquals("0.#E0: 123", "1.2E2", df.format(123));
+        assertEquals("0.#E0: 1234", "1.2E3", df.format(1234));
+        assertEquals("0.#E0: 9999", "1E4", df.format(9999));
 
         assertTrue("Failed " + failures + " of " + failCount,
                 failures.length() == 0);
@@ -1149,7 +1148,6 @@
         Currency currK = Currency.getInstance("KRW");
         Currency currX = Currency.getInstance("XXX");
         Currency currE = Currency.getInstance("EUR");
-        //Currency currF = Currency.getInstance("FRF");
 
         DecimalFormat df = (DecimalFormat) NumberFormat
                 .getCurrencyInstance(new Locale("ko", "KR"));
@@ -1183,11 +1181,11 @@
      */
     public void test_getGroupingSize() {
         DecimalFormat df = new DecimalFormat("###0.##");
-		assertEquals("Wrong unset size", 0, df.getGroupingSize());
+        assertEquals("Wrong unset size", 0, df.getGroupingSize());
         df = new DecimalFormat("#,##0.##");
-		assertEquals("Wrong set size", 3, df.getGroupingSize());
+        assertEquals("Wrong set size", 3, df.getGroupingSize());
         df = new DecimalFormat("#,###,###0.##");
-		assertEquals("Wrong multiple set size", 4, df.getGroupingSize());
+        assertEquals("Wrong multiple set size", 4, df.getGroupingSize());
     }
 
     /**
@@ -1195,16 +1193,16 @@
      */
     public void test_getMultiplier() {
         final int defaultMultiplier = 1;
-        NumberFormat nform = DecimalFormat.getInstance();
+        NumberFormat nform = DecimalFormat.getInstance(Locale.US);
         DecimalFormat form = (DecimalFormat) nform;
         assertEquals(defaultMultiplier, form.getMultiplier());
-        
+
         DecimalFormat df = new DecimalFormat("###0.##");
-		assertEquals("Wrong unset multiplier", 1, df.getMultiplier());
+        assertEquals("Wrong unset multiplier", 1, df.getMultiplier());
         df = new DecimalFormat("###0.##%");
-		assertEquals("Wrong percent multiplier", 100, df.getMultiplier());
+        assertEquals("Wrong percent multiplier", 100, df.getMultiplier());
         df = new DecimalFormat("###0.##\u2030");
-		assertEquals("Wrong mille multiplier", 1000, df.getMultiplier());
+        assertEquals("Wrong mille multiplier", 1000, df.getMultiplier());
     }
 
     /**
@@ -1323,7 +1321,7 @@
         df.setDecimalFormatSymbols(dfs);
         assertTrue("Not set", df.getDecimalFormatSymbols().equals(dfs));
         assertEquals("Symbols not used", "1@2", df.format(1.2));
-        
+
         // The returned symbols may be cloned in two spots
         // 1. When set
         // 2. When returned
@@ -1339,10 +1337,10 @@
      */
     public void test_setDecimalSeparatorAlwaysShownZ() {
         DecimalFormat df = new DecimalFormat("###0.##");
-		assertEquals("Wrong default result", "5", df.format(5));
+        assertEquals("Wrong default result", "5", df.format(5));
         df.setDecimalSeparatorAlwaysShown(true);
         assertTrue("Not set", df.isDecimalSeparatorAlwaysShown());
-		assertEquals("Wrong set result", "7.", df.format(7));
+        assertEquals("Wrong set result", "7.", df.format(7));
     }
 
     /**
@@ -1379,7 +1377,7 @@
                 new DecimalFormatSymbols(Locale.ENGLISH));
         df.setGroupingUsed(true);
         df.setGroupingSize(2);
-		assertEquals("Value not set", 2, df.getGroupingSize());
+        assertEquals("Value not set", 2, df.getGroupingSize());
         String result = df.format(123);
         assertTrue("Invalid format:" + result, result.equals("1,23"));
     }
@@ -1390,11 +1388,11 @@
     public void test_setMaximumFractionDigitsI() {
         DecimalFormat df = new DecimalFormat("###0.##");
         df.setMaximumFractionDigits(3);
-		assertEquals("Not set", 3, df.getMaximumFractionDigits());
-		assertEquals("Wrong maximum", "1.235", df.format(1.23456));
+        assertEquals("Not set", 3, df.getMaximumFractionDigits());
+        assertEquals("Wrong maximum", "1.235", df.format(1.23456));
         df.setMinimumFractionDigits(4);
-		assertEquals("Not changed", 4, df.getMaximumFractionDigits());
-		assertEquals("Incorrect fraction", "456.0000", df.format(456));
+        assertEquals("Not changed", 4, df.getMaximumFractionDigits());
+        assertEquals("Incorrect fraction", "456.0000", df.format(456));
     }
 
     /**
@@ -1403,11 +1401,11 @@
     public void test_setMaximumIntegerDigitsI() {
         DecimalFormat df = new DecimalFormat("###0.##");
         df.setMaximumIntegerDigits(2);
-		assertEquals("Not set", 2, df.getMaximumIntegerDigits());
-		assertEquals("Wrong maximum", "34", df.format(1234));
+        assertEquals("Not set", 2, df.getMaximumIntegerDigits());
+        assertEquals("Wrong maximum", "34", df.format(1234));
         df.setMinimumIntegerDigits(4);
-		assertEquals("Not changed", 4, df.getMaximumIntegerDigits());
-		assertEquals("Incorrect integer", "0026", df.format(26));
+        assertEquals("Not changed", 4, df.getMaximumIntegerDigits());
+        assertEquals("Incorrect integer", "0026", df.format(26));
     }
 
     /**
@@ -1416,11 +1414,11 @@
     public void test_setMinimumFractionDigitsI() {
         DecimalFormat df = new DecimalFormat("###0.##");
         df.setMinimumFractionDigits(4);
-		assertEquals("Not set", 4, df.getMinimumFractionDigits());
-		assertEquals("Wrong minimum", "1.2300", df.format(1.23));
+        assertEquals("Not set", 4, df.getMinimumFractionDigits());
+        assertEquals("Wrong minimum", "1.2300", df.format(1.23));
         df.setMaximumFractionDigits(2);
-		assertEquals("Not changed", 2, df.getMinimumFractionDigits());
-		assertEquals("Incorrect fraction", "456.00", df.format(456));
+        assertEquals("Not changed", 2, df.getMinimumFractionDigits());
+        assertEquals("Incorrect fraction", "456.00", df.format(456));
     }
 
     /**
@@ -1429,11 +1427,11 @@
     public void test_setMinimumIntegerDigitsI() {
         DecimalFormat df = new DecimalFormat("###0.##");
         df.setMinimumIntegerDigits(3);
-		assertEquals("Not set", 3, df.getMinimumIntegerDigits());
-		assertEquals("Wrong minimum", "012", df.format(12));
+        assertEquals("Not set", 3, df.getMinimumIntegerDigits());
+        assertEquals("Wrong minimum", "012", df.format(12));
         df.setMaximumIntegerDigits(2);
-		assertEquals("Not changed", 2, df.getMinimumIntegerDigits());
-		assertEquals("Incorrect integer", "00.7", df.format(0.7));
+        assertEquals("Not changed", 2, df.getMinimumIntegerDigits());
+        assertEquals("Incorrect integer", "00.7", df.format(0.7));
     }
 
     /**
@@ -1442,9 +1440,78 @@
     public void test_setMultiplierI() {
         DecimalFormat df = new DecimalFormat("###0.##");
         df.setMultiplier(10);
-		assertEquals("Wrong multiplier", 10, df.getMultiplier());
-		assertEquals("Wrong format", "50", df.format(5));
-		assertEquals("Wrong parse", 5, df.parse("50", new ParsePosition(0))
-				.intValue());
+        assertEquals("Wrong multiplier", 10, df.getMultiplier());
+        assertEquals("Wrong format", "50", df.format(5));
+        assertEquals("Wrong parse", 5, df.parse("50", new ParsePosition(0))
+                .intValue());
+    }
+
+    /**
+     * @tests serialization/deserialization
+     */
+    public void test_serializationHarmonyCompatible() throws Exception {
+        DecimalFormat df = new DecimalFormat();
+        assertTrue(SerializationTester.assertEquals(df));
+    }
+
+    /**
+     * @tests serialization compatibility with RI
+     */
+    public void test_serializationHarmonyRICompatible() {
+        NumberFormat nf = NumberFormat.getInstance(Locale.FRANCE);
+
+        DecimalFormat df = null;
+        if (!(nf instanceof DecimalFormat)) {
+            throw new Error("This NumberFormat is not a DecimalFormat");
+
+        }
+        df = (DecimalFormat) nf;
+
+        ObjectInputStream oinput = null;
+
+        DecimalFormat deserializedDF = null;
+
+        try {
+            oinput = new ObjectInputStream(this.getClass().getResource(
+                    "/serialization/java/text/DecimalFormat.ser").openStream());
+            deserializedDF = (DecimalFormat) oinput.readObject();
+        } catch (Exception e) {
+            fail("Error occurs during deserialization");
+        } finally {
+            try {
+                if (null != oinput) {
+                    oinput.close();
+                }
+            } catch (Exception e) {
+                // ignore
+            }
+        }
+
+        assertEquals(df.getNegativePrefix(), deserializedDF.getNegativePrefix());
+        assertEquals(df.getNegativeSuffix(), deserializedDF.getNegativeSuffix());
+        assertEquals(df.getPositivePrefix(), deserializedDF.getPositivePrefix());
+        assertEquals(df.getPositiveSuffix(), deserializedDF.getPositiveSuffix());
+        assertEquals(df.getCurrency(), deserializedDF.getCurrency());
+
+        assertEquals(df.getDecimalFormatSymbols(), deserializedDF
+                .getDecimalFormatSymbols());
+
+        assertEquals(df.getGroupingSize(), df.getGroupingSize());
+        assertEquals(df.getMaximumFractionDigits(), deserializedDF
+                .getMaximumFractionDigits());
+
+        assertEquals(df.getMaximumIntegerDigits(), deserializedDF
+                .getMaximumIntegerDigits());
+
+        assertEquals(df.getMinimumFractionDigits(), deserializedDF
+                .getMinimumFractionDigits());
+        assertEquals(df.getMinimumIntegerDigits(), deserializedDF
+                .getMinimumIntegerDigits());
+        assertEquals(df.getMultiplier(), deserializedDF.getMultiplier());
+
+        // Delibrately omitted this assertion. Since different data resource
+        // will cause the assertion fail.
+        // assertEquals(df, deserializedDF);
+
     }
 }

Added: incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/resources/serialization/java/text/DecimalFormat.ser
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/resources/serialization/java/text/DecimalFormat.ser?rev=404992&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/resources/serialization/java/text/DecimalFormat.ser
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream



Mime
View raw message