You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by lv...@apache.org on 2008/04/23 11:33:06 UTC
svn commit: r650808 - in
/harmony/enhanced/classlib/branches/java6/modules/text/src:
main/java/java/text/ test/java/org/apache/harmony/text/tests/java/text/
test/resources/serialization/org/ test/resources/serialization/org/apache/
test/resources/seria...
Author: lvjing
Date: Wed Apr 23 02:33:01 2008
New Revision: 650808
URL: http://svn.apache.org/viewvc?rev=650808&view=rev
Log:
Apply patch for HARMONY-5774, [java6][classlib][text] - implement getExponentSeparator and setExponentSeparator in DecimalFormatSymbols class
Added:
harmony/enhanced/classlib/branches/java6/modules/text/src/test/resources/serialization/org/
harmony/enhanced/classlib/branches/java6/modules/text/src/test/resources/serialization/org/apache/
harmony/enhanced/classlib/branches/java6/modules/text/src/test/resources/serialization/org/apache/harmony/
harmony/enhanced/classlib/branches/java6/modules/text/src/test/resources/serialization/org/apache/harmony/text/
harmony/enhanced/classlib/branches/java6/modules/text/src/test/resources/serialization/org/apache/harmony/text/tests/
harmony/enhanced/classlib/branches/java6/modules/text/src/test/resources/serialization/org/apache/harmony/text/tests/java/
harmony/enhanced/classlib/branches/java6/modules/text/src/test/resources/serialization/org/apache/harmony/text/tests/java/text/
harmony/enhanced/classlib/branches/java6/modules/text/src/test/resources/serialization/org/apache/harmony/text/tests/java/text/DecimalFormatSymbolsTest.golden.ser (with props)
Modified:
harmony/enhanced/classlib/branches/java6/modules/text/src/main/java/java/text/DecimalFormatSymbols.java
harmony/enhanced/classlib/branches/java6/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/DecimalFormatSymbolsTest.java
Modified: harmony/enhanced/classlib/branches/java6/modules/text/src/main/java/java/text/DecimalFormatSymbols.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/text/src/main/java/java/text/DecimalFormatSymbols.java?rev=650808&r1=650807&r2=650808&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/text/src/main/java/java/text/DecimalFormatSymbols.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/text/src/main/java/java/text/DecimalFormatSymbols.java Wed Apr 23 02:33:01 2008
@@ -58,7 +58,7 @@
private transient Locale locale;
- private String infinity, NaN, currencySymbol, intlCurrencySymbol;
+ private String infinity, NaN, currencySymbol, intlCurrencySymbol, exponentialSeparator;
/**
* Constructs a new DecimalFormatSymbols containing the symbols for the
@@ -83,6 +83,7 @@
this.locale = locale;
currencySymbol = icuSymbols.getCurrencySymbol();
intlCurrencySymbol = icuSymbols.getInternationalCurrencySymbol();
+ exponentialSeparator = icuSymbols.getExponentSeparator();
if (locale.getCountry().length() == 0) {
currency = Currency.getInstance("XXX");
} else {
@@ -235,7 +236,8 @@
return Arrays.equals(patternChars, obj.patternChars)
&& infinity.equals(obj.infinity) && NaN.equals(obj.NaN)
&& currencySymbol.equals(obj.currencySymbol)
- && intlCurrencySymbol.equals(obj.intlCurrencySymbol);
+ && intlCurrencySymbol.equals(obj.intlCurrencySymbol)
+ && exponentialSeparator.equals(obj.exponentialSeparator);
}
/**
@@ -299,7 +301,7 @@
* @return a String
*/
public String getExponentSeparator() {
- throw new NotImplementedException();
+ return exponentialSeparator;
}
/**
@@ -406,7 +408,7 @@
public int hashCode() {
return new String(patternChars).hashCode() + infinity.hashCode()
+ NaN.hashCode() + currencySymbol.hashCode()
- + intlCurrencySymbol.hashCode();
+ + intlCurrencySymbol.hashCode() + exponentialSeparator.hashCode();
}
/**
@@ -502,7 +504,10 @@
* the exponent separator String
*/
public void setExponentSeparator(String value) {
- throw new NotImplementedException();
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ exponentialSeparator = value;
}
/**
@@ -617,7 +622,8 @@
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$
+ new ObjectStreamField("locale", Locale.class), //$NON-NLS-1$
+ new ObjectStreamField("exponentSeparator", String.class) }; //$NON-NLS-1$
private void writeObject(ObjectOutputStream stream) throws IOException {
ObjectOutputStream.PutField fields = stream.putFields();
@@ -637,6 +643,7 @@
fields.put("serialVersionOnStream", 1); //$NON-NLS-1$
fields.put("zeroDigit", getZeroDigit()); //$NON-NLS-1$
fields.put("locale", locale); //$NON-NLS-1$
+ fields.put("exponentSeparator", getExponentSeparator()); //$NON-NLS-1$
stream.writeFields();
}
@@ -657,7 +664,8 @@
setPerMill(fields.get("perMill", '\u2030')); //$NON-NLS-1$
setZeroDigit(fields.get("zeroDigit", '0')); //$NON-NLS-1$
locale = (Locale) fields.get("locale", null); //$NON-NLS-1$
- if (fields.get("serialVersionOnStream", 0) == 0) { //$NON-NLS-1$
+ int serialVersionOnStream = fields.get("serialVersionOnStream", 0); //$NON-NLS-1$
+ if (serialVersionOnStream == 0) {
setMonetaryDecimalSeparator(getDecimalSeparator());
setExponential('E');
} else {
@@ -665,6 +673,13 @@
setExponential(fields.get("exponential", 'E')); //$NON-NLS-1$
}
+
+ if (serialVersionOnStream < 3) {
+ setExponentSeparator(String.valueOf(getExponential())); //$NON-NLS-1$
+ } else {
+ setExponentSeparator((String) fields.get("exponentialSeparator", "E"));
+ }
+
try {
currency = Currency.getInstance(intlCurrencySymbol);
} catch (IllegalArgumentException e) {
Modified: harmony/enhanced/classlib/branches/java6/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/DecimalFormatSymbolsTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/DecimalFormatSymbolsTest.java?rev=650808&r1=650807&r2=650808&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/DecimalFormatSymbolsTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/DecimalFormatSymbolsTest.java Wed Apr 23 02:33:01 2008
@@ -32,6 +32,7 @@
import junit.framework.TestCase;
+import org.apache.harmony.testframework.serialization.SerializationTest;
import org.apache.harmony.text.tests.java.text.MockedDecimalFormatSymbolsProvider.MockedDecimalFormatSymbols;
public class DecimalFormatSymbolsTest extends TestCase {
@@ -318,6 +319,15 @@
}
/**
+ * @tests java.text.DecimalFormatSymbols#getExponentSeparator()
+ */
+ public void test_getExponentSeparator() {
+ dfs.setExponentSeparator("EE");
+ assertEquals("Returned incorrect Exponent Separator symbol", "EE", dfs
+ .getExponentSeparator());
+ }
+
+ /**
* @tests java.text.DecimalFormatSymbols#getGroupingSeparator()
*/
public void test_getGroupingSeparator() {
@@ -436,6 +446,30 @@
}
/**
+ * @tests java.text.DecimalFormatSymbols#setExponentSeparator(String)
+ */
+ public void test_setExponentSeparator() {
+ try {
+ dfs.setExponentSeparator(null);
+ fail("Should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // expected
+ }
+
+ dfs.setExponentSeparator("");
+ assertEquals("Returned incorrect Exponent Separator symbol", "", dfs
+ .getExponentSeparator());
+
+ dfs.setExponentSeparator("what ever you want");
+ assertEquals("Returned incorrect Exponent Separator symbol",
+ "what ever you want", dfs.getExponentSeparator());
+
+ dfs.setExponentSeparator(" E ");
+ assertEquals("Returned incorrect Exponent Separator symbol", " E ", dfs
+ .getExponentSeparator());
+ }
+
+ /**
* @tests java.text.DecimalFormatSymbols#setGroupingSeparator(char)
*/
public void test_setGroupingSeparatorC() {
@@ -595,5 +629,23 @@
// ignore
}
}
+ }
+
+ /**
+ * @tests serialization/deserialization compatibility with RI6.
+ */
+ public void testSerializationCompatibility() throws Exception {
+ DecimalFormatSymbols symbols = new DecimalFormatSymbols(Locale.US);
+ symbols.setExponentSeparator("EE");
+ symbols.setNaN("NaN");
+ SerializationTest.verifyGolden(this, symbols);
+ }
+
+ /**
+ * @tests serialization/deserialization compatibility.
+ */
+ public void testSerializationSelf() throws Exception {
+ DecimalFormatSymbols symbols = new DecimalFormatSymbols(Locale.ITALIAN);
+ SerializationTest.verifySelf(symbols);
}
}
Added: harmony/enhanced/classlib/branches/java6/modules/text/src/test/resources/serialization/org/apache/harmony/text/tests/java/text/DecimalFormatSymbolsTest.golden.ser
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/text/src/test/resources/serialization/org/apache/harmony/text/tests/java/text/DecimalFormatSymbolsTest.golden.ser?rev=650808&view=auto
==============================================================================
Binary file - no diff available.
Propchange: harmony/enhanced/classlib/branches/java6/modules/text/src/test/resources/serialization/org/apache/harmony/text/tests/java/text/DecimalFormatSymbolsTest.golden.ser
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream