437 |
* @throws NullPointerException if any argument is null. |
* @throws NullPointerException if any argument is null. |
438 |
* @throws IllegalArgumentException if the pattern is invalid. |
* @throws IllegalArgumentException if the pattern is invalid. |
439 |
*/ |
*/ |
440 |
public DecimalFormat (String pattern, DecimalFormatSymbols symbols) |
public DecimalFormat(String pattern, DecimalFormatSymbols symbols) |
441 |
{ |
{ |
442 |
if (symbols == null) |
this.symbols = (DecimalFormatSymbols) symbols.clone(); |
|
{ |
|
|
throw new NullPointerException("Supplied set of symbols is null."); |
|
|
} |
|
|
this.symbols = symbols; |
|
443 |
applyPattern(pattern); |
applyPattern(pattern); |
444 |
} |
} |
445 |
|
|
450 |
return s1.equals(s2); |
return s1.equals(s2); |
451 |
} |
} |
452 |
|
|
453 |
public boolean equals (Object obj) |
/** |
454 |
|
* Tests this instance for equality with an arbitrary object. This method |
455 |
|
* returns <code>true</code> if: |
456 |
|
* <ul> |
457 |
|
* <li><code>obj</code> is not <code>null</code>;</li> |
458 |
|
* <li><code>obj</code> is an instance of <code>DecimalFormat</code>;</li> |
459 |
|
* <li>this instance and <code>obj</code> have the same attributes;</li> |
460 |
|
* </ul> |
461 |
|
* |
462 |
|
* @param obj the object (<code>null</code> permitted). |
463 |
|
* |
464 |
|
* @return A boolean. |
465 |
|
*/ |
466 |
|
public boolean equals(Object obj) |
467 |
{ |
{ |
468 |
if (! (obj instanceof DecimalFormat)) |
if (! (obj instanceof DecimalFormat)) |
469 |
return false; |
return false; |
470 |
DecimalFormat dup = (DecimalFormat) obj; |
DecimalFormat dup = (DecimalFormat) obj; |
471 |
return (decimalSeparatorAlwaysShown == dup.decimalSeparatorAlwaysShown |
return (decimalSeparatorAlwaysShown == dup.decimalSeparatorAlwaysShown |
472 |
&& groupingSize == dup.groupingSize |
&& groupingUsed == dup.groupingUsed |
473 |
&& minExponentDigits == dup.minExponentDigits |
&& groupingSize == dup.groupingSize |
474 |
&& multiplier == dup.multiplier |
&& multiplier == dup.multiplier |
475 |
&& equals(negativePrefix, dup.negativePrefix) |
&& useExponentialNotation == dup.useExponentialNotation |
476 |
&& equals(negativeSuffix, dup.negativeSuffix) |
&& minExponentDigits == dup.minExponentDigits |
477 |
&& equals(positivePrefix, dup.positivePrefix) |
&& minimumIntegerDigits == dup.minimumIntegerDigits |
478 |
&& equals(positiveSuffix, dup.positiveSuffix) |
&& maximumIntegerDigits == dup.maximumIntegerDigits |
479 |
&& symbols.equals(dup.symbols) |
&& minimumFractionDigits == dup.minimumFractionDigits |
480 |
&& useExponentialNotation == dup.useExponentialNotation); |
&& maximumFractionDigits == dup.maximumFractionDigits |
481 |
|
&& equals(negativePrefix, dup.negativePrefix) |
482 |
|
&& equals(negativeSuffix, dup.negativeSuffix) |
483 |
|
&& equals(positivePrefix, dup.positivePrefix) |
484 |
|
&& equals(positiveSuffix, dup.positiveSuffix) |
485 |
|
&& symbols.equals(dup.symbols)); |
486 |
} |
} |
487 |
|
|
488 |
private void formatInternal (double number, FormatBuffer dest, |
private void formatInternal (double number, FormatBuffer dest, |
798 |
return symbols.getCurrency(); |
return symbols.getCurrency(); |
799 |
} |
} |
800 |
|
|
801 |
public DecimalFormatSymbols getDecimalFormatSymbols () |
/** |
802 |
|
* Returns a copy of the symbols used by this instance. |
803 |
|
* |
804 |
|
* @return A copy of the symbols. |
805 |
|
*/ |
806 |
|
public DecimalFormatSymbols getDecimalFormatSymbols() |
807 |
{ |
{ |
808 |
return symbols; |
return (DecimalFormatSymbols) symbols.clone(); |
809 |
} |
} |
810 |
|
|
811 |
public int getGroupingSize () |
public int getGroupingSize () |
1152 |
symbols.setCurrency(currency); |
symbols.setCurrency(currency); |
1153 |
} |
} |
1154 |
|
|
1155 |
public void setDecimalFormatSymbols (DecimalFormatSymbols newSymbols) |
/** |
1156 |
|
* Sets the symbols used by this instance. This method makes a copy of |
1157 |
|
* the supplied symbols. |
1158 |
|
* |
1159 |
|
* @param newSymbols the symbols (<code>null</code> not permitted). |
1160 |
|
*/ |
1161 |
|
public void setDecimalFormatSymbols(DecimalFormatSymbols newSymbols) |
1162 |
{ |
{ |
1163 |
symbols = newSymbols; |
symbols = (DecimalFormatSymbols) newSymbols.clone(); |
1164 |
} |
} |
1165 |
|
|
1166 |
public void setDecimalSeparatorAlwaysShown (boolean newValue) |
public void setDecimalSeparatorAlwaysShown (boolean newValue) |