[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [cp-patches] java.text.DecimalFormat fixes
From: |
David Gilbert |
Subject: |
Re: [cp-patches] java.text.DecimalFormat fixes |
Date: |
Tue, 14 Jun 2005 11:20:25 +0000 |
User-agent: |
Mozilla Thunderbird 1.0.2 (X11/20050426) |
Thanks for the feedback, I amended the patch (see attached) and
committed it.
Regards,
Dave
Tom Tromey wrote:
>>>>>>"David" == David Gilbert <address@hidden> writes:
>>>>>>
>>>>>>
>
>David> Thanks, I missed that somehow. By the way, I'm not using emacs, and the
>David> original source has some tabs (which I'm sure I read should be avoided
>David> in Classpath), so how far should I indent each line here? Or since you
>David> didn't mention it, should I assume that the way I did it is OK?
>
>Yeah, the tabs/spaces thing continues to bug folks who don't use Emacs.
>The way it is supposed to work is that the continuation lines of the
>expression line up with the expression's start:
>
>return (x
> + y
> + z);
>
>And in case a mailer somewhere trashes that, each "+" lines up under
>the "x".
>
>Tom
>
>
>
Index: java/text/DecimalFormat.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/text/DecimalFormat.java,v
retrieving revision 1.22
diff -u -r1.22 DecimalFormat.java
--- java/text/DecimalFormat.java 2 May 2005 17:21:51 -0000 1.22
+++ java/text/DecimalFormat.java 14 Jun 2005 10:07:10 -0000
@@ -437,13 +437,9 @@
* @throws NullPointerException if any argument is null.
* @throws IllegalArgumentException if the pattern is invalid.
*/
- public DecimalFormat (String pattern, DecimalFormatSymbols symbols)
+ public DecimalFormat(String pattern, DecimalFormatSymbols symbols)
{
- if (symbols == null)
- {
- throw new NullPointerException("Supplied set of symbols is null.");
- }
- this.symbols = symbols;
+ this.symbols = (DecimalFormatSymbols) symbols.clone();
applyPattern(pattern);
}
@@ -454,21 +450,39 @@
return s1.equals(s2);
}
- public boolean equals (Object obj)
+ /**
+ * Tests this instance for equality with an arbitrary object. This method
+ * returns <code>true</code> if:
+ * <ul>
+ * <li><code>obj</code> is not <code>null</code>;</li>
+ * <li><code>obj</code> is an instance of <code>DecimalFormat</code>;</li>
+ * <li>this instance and <code>obj</code> have the same attributes;</li>
+ * </ul>
+ *
+ * @param obj the object (<code>null</code> permitted).
+ *
+ * @return A boolean.
+ */
+ public boolean equals(Object obj)
{
if (! (obj instanceof DecimalFormat))
return false;
DecimalFormat dup = (DecimalFormat) obj;
- return (decimalSeparatorAlwaysShown == dup.decimalSeparatorAlwaysShown
- && groupingSize == dup.groupingSize
- && minExponentDigits == dup.minExponentDigits
- && multiplier == dup.multiplier
- && equals(negativePrefix, dup.negativePrefix)
- && equals(negativeSuffix, dup.negativeSuffix)
- && equals(positivePrefix, dup.positivePrefix)
- && equals(positiveSuffix, dup.positiveSuffix)
- && symbols.equals(dup.symbols)
- && useExponentialNotation == dup.useExponentialNotation);
+ return (decimalSeparatorAlwaysShown == dup.decimalSeparatorAlwaysShown
+ && groupingUsed == dup.groupingUsed
+ && groupingSize == dup.groupingSize
+ && multiplier == dup.multiplier
+ && useExponentialNotation == dup.useExponentialNotation
+ && minExponentDigits == dup.minExponentDigits
+ && minimumIntegerDigits == dup.minimumIntegerDigits
+ && maximumIntegerDigits == dup.maximumIntegerDigits
+ && minimumFractionDigits == dup.minimumFractionDigits
+ && maximumFractionDigits == dup.maximumFractionDigits
+ && equals(negativePrefix, dup.negativePrefix)
+ && equals(negativeSuffix, dup.negativeSuffix)
+ && equals(positivePrefix, dup.positivePrefix)
+ && equals(positiveSuffix, dup.positiveSuffix)
+ && symbols.equals(dup.symbols));
}
private void formatInternal (double number, FormatBuffer dest,
@@ -784,9 +798,14 @@
return symbols.getCurrency();
}
- public DecimalFormatSymbols getDecimalFormatSymbols ()
+ /**
+ * Returns a copy of the symbols used by this instance.
+ *
+ * @return A copy of the symbols.
+ */
+ public DecimalFormatSymbols getDecimalFormatSymbols()
{
- return symbols;
+ return (DecimalFormatSymbols) symbols.clone();
}
public int getGroupingSize ()
@@ -1133,9 +1152,15 @@
symbols.setCurrency(currency);
}
- public void setDecimalFormatSymbols (DecimalFormatSymbols newSymbols)
+ /**
+ * Sets the symbols used by this instance. This method makes a copy of
+ * the supplied symbols.
+ *
+ * @param newSymbols the symbols (<code>null</code> not permitted).
+ */
+ public void setDecimalFormatSymbols(DecimalFormatSymbols newSymbols)
{
- symbols = newSymbols;
+ symbols = (DecimalFormatSymbols) newSymbols.clone();
}
public void setDecimalSeparatorAlwaysShown (boolean newValue)