LEFT | RIGHT |
(no file at all) | |
1 // © 2017 and later: Unicode, Inc. and others. | 1 // © 2017 and later: Unicode, Inc. and others. |
2 // License & terms of use: http://www.unicode.org/copyright.html#License | 2 // License & terms of use: http://www.unicode.org/copyright.html#License |
3 package com.ibm.icu.impl.number; | 3 package com.ibm.icu.impl.number; |
4 | 4 |
5 import java.io.IOException; | 5 import java.io.IOException; |
6 import java.io.ObjectInputStream; | 6 import java.io.ObjectInputStream; |
7 import java.io.ObjectOutputStream; | 7 import java.io.ObjectOutputStream; |
8 import java.io.Serializable; | 8 import java.io.Serializable; |
9 import java.lang.reflect.Field; | 9 import java.lang.reflect.Field; |
10 import java.lang.reflect.Modifier; | 10 import java.lang.reflect.Modifier; |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 /+--------------------------------------------------------------------------
------------------*/ | 98 /+--------------------------------------------------------------------------
------------------*/ |
99 | 99 |
100 public DecimalFormatProperties() { | 100 public DecimalFormatProperties() { |
101 clear(); | 101 clear(); |
102 } | 102 } |
103 | 103 |
104 /** | 104 /** |
105 * Sets all properties to their defaults (unset). | 105 * Sets all properties to their defaults (unset). |
106 * | 106 * |
107 * <p> | 107 * <p> |
108 * All integers default to -1 EXCEPT FOR MAGNITUDE MULTIPLIER which has a de
fault of 0 (since negative numbers are | 108 * All integers default to -1 EXCEPT FOR MAGNITUDE MULTIPLIER which has a de
fault of 0 (since |
109 * important). | 109 * negative numbers are important). |
110 * | 110 * |
111 * <p> | 111 * <p> |
112 * All booleans default to false. | 112 * All booleans default to false. |
113 * | 113 * |
114 * <p> | 114 * <p> |
115 * All non-primitive types default to null. | 115 * All non-primitive types default to null. |
116 * | 116 * |
117 * @return The property bag, for chaining. | 117 * @return The property bag, for chaining. |
118 */ | 118 */ |
119 private DecimalFormatProperties _clear() { | 119 private DecimalFormatProperties _clear() { |
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
543 @Override | 543 @Override |
544 public int hashCode() { | 544 public int hashCode() { |
545 return _hashCode(); | 545 return _hashCode(); |
546 } | 546 } |
547 | 547 |
548 /** Custom serialization: re-create object from serialized properties. */ | 548 /** Custom serialization: re-create object from serialized properties. */ |
549 private void readObject(ObjectInputStream ois) throws IOException, ClassNotF
oundException { | 549 private void readObject(ObjectInputStream ois) throws IOException, ClassNotF
oundException { |
550 readObjectImpl(ois); | 550 readObjectImpl(ois); |
551 } | 551 } |
552 | 552 |
553 /* package-private */ void readObjectImpl(ObjectInputStream ois) throws IOEx
ception, ClassNotFoundException { | 553 /* package-private */ void readObjectImpl(ObjectInputStream ois) |
| 554 throws IOException, ClassNotFoundException { |
554 ois.defaultReadObject(); | 555 ois.defaultReadObject(); |
555 | 556 |
556 // Initialize to empty | 557 // Initialize to empty |
557 clear(); | 558 clear(); |
558 | 559 |
559 // Extra int for possible future use | 560 // Extra int for possible future use |
560 ois.readInt(); | 561 ois.readInt(); |
561 | 562 |
562 // 1) How many fields were serialized? | 563 // 1) How many fields were serialized? |
563 int count = ois.readInt(); | 564 int count = ois.readInt(); |
(...skipping 25 matching lines...) Expand all Loading... |
589 // Should not happen | 590 // Should not happen |
590 throw new AssertionError(e); | 591 throw new AssertionError(e); |
591 } catch (IllegalAccessException e) { | 592 } catch (IllegalAccessException e) { |
592 // Should not happen | 593 // Should not happen |
593 throw new AssertionError(e); | 594 throw new AssertionError(e); |
594 } | 595 } |
595 } | 596 } |
596 } | 597 } |
597 | 598 |
598 /** | 599 /** |
599 * Specifies custom data to be used instead of CLDR data when constructing a
CompactDecimalFormat. The argument | 600 * Specifies custom data to be used instead of CLDR data when constructing a
CompactDecimalFormat. |
600 * should be a map with the following structure: | 601 * The argument should be a map with the following structure: |
601 * | 602 * |
602 * <pre> | 603 * <pre> |
603 * { | 604 * { |
604 * "1000": { | 605 * "1000": { |
605 * "one": "0 thousand", | 606 * "one": "0 thousand", |
606 * "other": "0 thousand" | 607 * "other": "0 thousand" |
607 * }, | 608 * }, |
608 * "10000": { | 609 * "10000": { |
609 * "one": "00 thousand", | 610 * "one": "00 thousand", |
610 * "other": "00 thousand" | 611 * "other": "00 thousand" |
611 * }, | 612 * }, |
612 * // ... | 613 * // ... |
613 * } | 614 * } |
614 * </pre> | 615 * </pre> |
615 * | 616 * |
616 * This API endpoint is used by the CLDR Survey Tool. | 617 * This API endpoint is used by the CLDR Survey Tool. |
617 * | 618 * |
618 * @param compactCustomData | 619 * @param compactCustomData |
619 * A map with the above structure. | 620 * A map with the above structure. |
620 * @return The property bag, for chaining. | 621 * @return The property bag, for chaining. |
621 */ | 622 */ |
622 public DecimalFormatProperties setCompactCustomData(Map<String, Map<String,
String>> compactCustomData) { | 623 public DecimalFormatProperties setCompactCustomData( |
| 624 Map<String, Map<String, String>> compactCustomData) { |
623 // TODO: compactCustomData is not immutable. | 625 // TODO: compactCustomData is not immutable. |
624 this.compactCustomData = compactCustomData; | 626 this.compactCustomData = compactCustomData; |
625 return this; | 627 return this; |
626 } | 628 } |
627 | 629 |
628 /** | 630 /** |
629 * Use compact decimal formatting with the specified {@link CompactStyle}. C
ompactStyle.SHORT produces output like | 631 * Use compact decimal formatting with the specified {@link CompactStyle}. C
ompactStyle.SHORT |
630 * "10K" in locale <em>en-US</em>, whereas CompactStyle.LONG produces output
like "10 thousand" in that locale. | 632 * produces output like "10K" in locale <em>en-US</em>, whereas CompactStyle
.LONG produces output |
| 633 * like "10 thousand" in that locale. |
631 * | 634 * |
632 * @param compactStyle | 635 * @param compactStyle |
633 * The style of prefixes/suffixes to append. | 636 * The style of prefixes/suffixes to append. |
634 * @return The property bag, for chaining. | 637 * @return The property bag, for chaining. |
635 */ | 638 */ |
636 public DecimalFormatProperties setCompactStyle(CompactStyle compactStyle) { | 639 public DecimalFormatProperties setCompactStyle(CompactStyle compactStyle) { |
637 this.compactStyle = compactStyle; | 640 this.compactStyle = compactStyle; |
638 return this; | 641 return this; |
639 } | 642 } |
640 | 643 |
(...skipping 20 matching lines...) Expand all Loading... |
661 // TODO: In order to maintain immutability, we have to perform a clone h
ere. | 664 // TODO: In order to maintain immutability, we have to perform a clone h
ere. |
662 // It would be better to just retire CurrencyPluralInfo entirely. | 665 // It would be better to just retire CurrencyPluralInfo entirely. |
663 if (currencyPluralInfo != null) { | 666 if (currencyPluralInfo != null) { |
664 currencyPluralInfo = (CurrencyPluralInfo) currencyPluralInfo.clone()
; | 667 currencyPluralInfo = (CurrencyPluralInfo) currencyPluralInfo.clone()
; |
665 } | 668 } |
666 this.currencyPluralInfo = currencyPluralInfo; | 669 this.currencyPluralInfo = currencyPluralInfo; |
667 return this; | 670 return this; |
668 } | 671 } |
669 | 672 |
670 /** | 673 /** |
671 * Use the specified {@link CurrencyUsage} instance, which provides default
rounding rules for the currency in two | 674 * Use the specified {@link CurrencyUsage} instance, which provides default
rounding rules for the |
672 * styles, CurrencyUsage.CASH and CurrencyUsage.STANDARD. | 675 * currency in two styles, CurrencyUsage.CASH and CurrencyUsage.STANDARD. |
673 * | 676 * |
674 * <p> | 677 * <p> |
675 * The CurrencyUsage specified here will not be used unless there is a curre
ncy placeholder in the pattern. | 678 * The CurrencyUsage specified here will not be used unless there is a curre
ncy placeholder in the |
| 679 * pattern. |
676 * | 680 * |
677 * @param currencyUsage | 681 * @param currencyUsage |
678 * The currency usage. Defaults to CurrencyUsage.STANDARD. | 682 * The currency usage. Defaults to CurrencyUsage.STANDARD. |
679 * @return The property bag, for chaining. | 683 * @return The property bag, for chaining. |
680 */ | 684 */ |
681 public DecimalFormatProperties setCurrencyUsage(CurrencyUsage currencyUsage)
{ | 685 public DecimalFormatProperties setCurrencyUsage(CurrencyUsage currencyUsage)
{ |
682 this.currencyUsage = currencyUsage; | 686 this.currencyUsage = currencyUsage; |
683 return this; | 687 return this; |
684 } | 688 } |
685 | 689 |
686 /** | 690 /** |
687 * PARSING: Whether to require that the presence of decimal point matches th
e pattern. If a decimal point is not | 691 * PARSING: Whether to require that the presence of decimal point matches th
e pattern. If a decimal |
688 * present, but the pattern contained a decimal point, parse will not succee
d: null will be returned from | 692 * point is not present, but the pattern contained a decimal point, parse wi
ll not succeed: null will |
689 * <code>parse()</code>, and an error index will be set in the {@link ParseP
osition}. | 693 * be returned from <code>parse()</code>, and an error index will be set in
the |
| 694 * {@link ParsePosition}. |
690 * | 695 * |
691 * @param decimalPatternMatchRequired | 696 * @param decimalPatternMatchRequired |
692 * true to set an error if decimal is not present | 697 * true to set an error if decimal is not present |
693 * @return The property bag, for chaining. | 698 * @return The property bag, for chaining. |
694 */ | 699 */ |
695 public DecimalFormatProperties setDecimalPatternMatchRequired(boolean decima
lPatternMatchRequired) { | 700 public DecimalFormatProperties setDecimalPatternMatchRequired(boolean decima
lPatternMatchRequired) { |
696 this.decimalPatternMatchRequired = decimalPatternMatchRequired; | 701 this.decimalPatternMatchRequired = decimalPatternMatchRequired; |
697 return this; | 702 return this; |
698 } | 703 } |
699 | 704 |
700 /** | 705 /** |
701 * Sets whether to always show the decimal point, even if the number doesn't
require one. For example, if always | 706 * Sets whether to always show the decimal point, even if the number doesn't
require one. For |
702 * show decimal is true, the number 123 would be formatted as "123." in loca
le <em>en-US</em>. | 707 * example, if always show decimal is true, the number 123 would be formatte
d as "123." in locale |
| 708 * <em>en-US</em>. |
703 * | 709 * |
704 * @param alwaysShowDecimal | 710 * @param alwaysShowDecimal |
705 * Whether to show the decimal point when it is optional. | 711 * Whether to show the decimal point when it is optional. |
706 * @return The property bag, for chaining. | 712 * @return The property bag, for chaining. |
707 */ | 713 */ |
708 public DecimalFormatProperties setDecimalSeparatorAlwaysShown(boolean always
ShowDecimal) { | 714 public DecimalFormatProperties setDecimalSeparatorAlwaysShown(boolean always
ShowDecimal) { |
709 this.decimalSeparatorAlwaysShown = alwaysShowDecimal; | 715 this.decimalSeparatorAlwaysShown = alwaysShowDecimal; |
710 return this; | 716 return this; |
711 } | 717 } |
712 | 718 |
713 /** | 719 /** |
714 * Sets whether to show the plus sign in the exponent part of numbers with a
zero or positive exponent. For example, | 720 * Sets whether to show the plus sign in the exponent part of numbers with a
zero or positive |
715 * the number "1200" with the pattern "0.0E0" would be formatted as "1.2E+3"
instead of "1.2E3" in <em>en-US</em>. | 721 * exponent. For example, the number "1200" with the pattern "0.0E0" would b
e formatted as "1.2E+3" |
| 722 * instead of "1.2E3" in <em>en-US</em>. |
716 * | 723 * |
717 * @param exponentSignAlwaysShown | 724 * @param exponentSignAlwaysShown |
718 * Whether to show the plus sign in positive exponents. | 725 * Whether to show the plus sign in positive exponents. |
719 * @return The property bag, for chaining. | 726 * @return The property bag, for chaining. |
720 */ | 727 */ |
721 public DecimalFormatProperties setExponentSignAlwaysShown(boolean exponentSi
gnAlwaysShown) { | 728 public DecimalFormatProperties setExponentSignAlwaysShown(boolean exponentSi
gnAlwaysShown) { |
722 this.exponentSignAlwaysShown = exponentSignAlwaysShown; | 729 this.exponentSignAlwaysShown = exponentSignAlwaysShown; |
723 return this; | 730 return this; |
724 } | 731 } |
725 | 732 |
726 /** | 733 /** |
727 * Sets the minimum width of the string output by the formatting pipeline. F
or example, if padding is enabled and | 734 * Sets the minimum width of the string output by the formatting pipeline. F
or example, if padding is |
728 * paddingWidth is set to 6, formatting the number "3.14159" with the patter
n "0.00" will result in "··3.14" if '·' | 735 * enabled and paddingWidth is set to 6, formatting the number "3.14159" wit
h the pattern "0.00" will |
729 * is your padding string. | 736 * result in "··3.14" if '·' is your padding string. |
730 * | 737 * |
731 * <p> | 738 * <p> |
732 * If the number is longer than your padding width, the number will display
as if no padding width had been | 739 * If the number is longer than your padding width, the number will display
as if no padding width |
733 * specified, which may result in strings longer than the padding width. | 740 * had been specified, which may result in strings longer than the padding w
idth. |
734 * | 741 * |
735 * <p> | 742 * <p> |
736 * Width is counted in UTF-16 code units. | 743 * Width is counted in UTF-16 code units. |
737 * | 744 * |
738 * @param paddingWidth | 745 * @param paddingWidth |
739 * The output width. | 746 * The output width. |
740 * @return The property bag, for chaining. | 747 * @return The property bag, for chaining. |
741 * @see #setPadPosition | 748 * @see #setPadPosition |
742 * @see #setPadString | 749 * @see #setPadString |
743 */ | 750 */ |
744 public DecimalFormatProperties setFormatWidth(int paddingWidth) { | 751 public DecimalFormatProperties setFormatWidth(int paddingWidth) { |
745 this.formatWidth = paddingWidth; | 752 this.formatWidth = paddingWidth; |
746 return this; | 753 return this; |
747 } | 754 } |
748 | 755 |
749 /** | 756 /** |
750 * Sets the number of digits between grouping separators. For example, the <
em>en-US</em> locale uses a grouping | 757 * Sets the number of digits between grouping separators. For example, the <
em>en-US</em> locale uses |
751 * size of 3, so the number 1234567 would be formatted as "1,234,567". For l
ocales whose grouping sizes vary with | 758 * a grouping size of 3, so the number 1234567 would be formatted as "1,234,
567". For locales whose |
752 * magnitude, see {@link #setSecondaryGroupingSize(int)}. | 759 * grouping sizes vary with magnitude, see {@link #setSecondaryGroupingSize(
int)}. |
753 * | 760 * |
754 * @param groupingSize | 761 * @param groupingSize |
755 * The primary grouping size. | 762 * The primary grouping size. |
756 * @return The property bag, for chaining. | 763 * @return The property bag, for chaining. |
757 */ | 764 */ |
758 public DecimalFormatProperties setGroupingSize(int groupingSize) { | 765 public DecimalFormatProperties setGroupingSize(int groupingSize) { |
759 this.groupingSize = groupingSize; | 766 this.groupingSize = groupingSize; |
760 return this; | 767 return this; |
761 } | 768 } |
762 | 769 |
763 /** | 770 /** |
764 * Multiply all numbers by this power of ten before formatting. Negative mul
tipliers reduce the magnitude and make | 771 * Multiply all numbers by this power of ten before formatting. Negative mul
tipliers reduce the |
765 * numbers smaller (closer to zero). | 772 * magnitude and make numbers smaller (closer to zero). |
766 * | 773 * |
767 * @param magnitudeMultiplier | 774 * @param magnitudeMultiplier |
768 * The number of powers of ten to scale. | 775 * The number of powers of ten to scale. |
769 * @return The property bag, for chaining. | 776 * @return The property bag, for chaining. |
770 * @see #setMultiplier | 777 * @see #setMultiplier |
771 */ | 778 */ |
772 public DecimalFormatProperties setMagnitudeMultiplier(int magnitudeMultiplie
r) { | 779 public DecimalFormatProperties setMagnitudeMultiplier(int magnitudeMultiplie
r) { |
773 this.magnitudeMultiplier = magnitudeMultiplier; | 780 this.magnitudeMultiplier = magnitudeMultiplier; |
774 return this; | 781 return this; |
775 } | 782 } |
776 | 783 |
777 /** | 784 /** |
778 * Sets the {@link MathContext} to be used during math and rounding operatio
ns. A MathContext encapsulates a | 785 * Sets the {@link MathContext} to be used during math and rounding operatio
ns. A MathContext |
779 * RoundingMode and the number of significant digits in the output. | 786 * encapsulates a RoundingMode and the number of significant digits in the o
utput. |
780 * | 787 * |
781 * @param mathContext | 788 * @param mathContext |
782 * The math context to use when rounding is required. | 789 * The math context to use when rounding is required. |
783 * @return The property bag, for chaining. | 790 * @return The property bag, for chaining. |
784 * @see MathContext | 791 * @see MathContext |
785 * @see #setRoundingMode | 792 * @see #setRoundingMode |
786 */ | 793 */ |
787 public DecimalFormatProperties setMathContext(MathContext mathContext) { | 794 public DecimalFormatProperties setMathContext(MathContext mathContext) { |
788 this.mathContext = mathContext; | 795 this.mathContext = mathContext; |
789 return this; | 796 return this; |
790 } | 797 } |
791 | 798 |
792 /** | 799 /** |
793 * Sets the maximum number of digits to display after the decimal point. If
the number has fewer than this number of | 800 * Sets the maximum number of digits to display after the decimal point. If
the number has fewer than |
794 * digits, the number will be rounded off using the rounding mode specified
by | 801 * this number of digits, the number will be rounded off using the rounding
mode specified by |
795 * {@link #setRoundingMode(RoundingMode)}. The pattern "#00.0#", for example
, corresponds to 2 maximum fraction | 802 * {@link #setRoundingMode(RoundingMode)}. The pattern "#00.0#", for example
, corresponds to 2 |
796 * digits, and the number 456.789 would be formatted as "456.79" in locale <
em>en-US</em> with the default rounding | 803 * maximum fraction digits, and the number 456.789 would be formatted as "45
6.79" in locale |
797 * mode. Note that the number 456.999 would be formatted as "457.0" given th
e same configurations. | 804 * <em>en-US</em> with the default rounding mode. Note that the number 456.9
99 would be formatted as |
| 805 * "457.0" given the same configurations. |
798 * | 806 * |
799 * @param maximumFractionDigits | 807 * @param maximumFractionDigits |
800 * The maximum number of fraction digits to output. | 808 * The maximum number of fraction digits to output. |
801 * @return The property bag, for chaining. | 809 * @return The property bag, for chaining. |
802 */ | 810 */ |
803 public DecimalFormatProperties setMaximumFractionDigits(int maximumFractionD
igits) { | 811 public DecimalFormatProperties setMaximumFractionDigits(int maximumFractionD
igits) { |
804 this.maximumFractionDigits = maximumFractionDigits; | 812 this.maximumFractionDigits = maximumFractionDigits; |
805 return this; | 813 return this; |
806 } | 814 } |
807 | 815 |
808 /** | 816 /** |
809 * Sets the maximum number of digits to display before the decimal point. If
the number has more than this number of | 817 * Sets the maximum number of digits to display before the decimal point. If
the number has more than |
810 * digits, the extra digits will be truncated. For example, if maximum integ
er digits is 2, and you attempt to | 818 * this number of digits, the extra digits will be truncated. For example, i
f maximum integer digits |
811 * format the number 1970, you will get "70" in locale <em>en-US</em>. It is
not possible to specify the maximum | 819 * is 2, and you attempt to format the number 1970, you will get "70" in loc
ale <em>en-US</em>. It is |
812 * integer digits using a pattern string, except in the special case of a sc
ientific format pattern. | 820 * not possible to specify the maximum integer digits using a pattern string
, except in the special |
| 821 * case of a scientific format pattern. |
813 * | 822 * |
814 * @param maximumIntegerDigits | 823 * @param maximumIntegerDigits |
815 * The maximum number of integer digits to output. | 824 * The maximum number of integer digits to output. |
816 * @return The property bag, for chaining. | 825 * @return The property bag, for chaining. |
817 */ | 826 */ |
818 public DecimalFormatProperties setMaximumIntegerDigits(int maximumIntegerDig
its) { | 827 public DecimalFormatProperties setMaximumIntegerDigits(int maximumIntegerDig
its) { |
819 this.maximumIntegerDigits = maximumIntegerDigits; | 828 this.maximumIntegerDigits = maximumIntegerDigits; |
820 return this; | 829 return this; |
821 } | 830 } |
822 | 831 |
823 /** | 832 /** |
824 * Sets the maximum number of significant digits to display. The number of s
ignificant digits is equal to the number | 833 * Sets the maximum number of significant digits to display. The number of s
ignificant digits is |
825 * of digits counted from the leftmost nonzero digit through the rightmost n
onzero digit; for example, the number | 834 * equal to the number of digits counted from the leftmost nonzero digit thr
ough the rightmost |
826 * "2010" has 3 significant digits. If the number has more significant digit
s than specified here, the extra | 835 * nonzero digit; for example, the number "2010" has 3 significant digits. I
f the number has more |
827 * significant digits will be rounded off using the rounding mode specified
by | 836 * significant digits than specified here, the extra significant digits will
be rounded off using the |
828 * {@link #setRoundingMode(RoundingMode)}. For example, if maximum significa
nt digits is 3, the number 1234.56 will | 837 * rounding mode specified by {@link #setRoundingMode(RoundingMode)}. For ex
ample, if maximum |
829 * be formatted as "1230" in locale <em>en-US</em> with the default rounding
mode. | 838 * significant digits is 3, the number 1234.56 will be formatted as "1230" i
n locale <em>en-US</em> |
830 * | 839 * with the default rounding mode. |
831 * <p> | 840 * |
832 * If both maximum significant digits and maximum integer/fraction digits ar
e set at the same time, the behavior is | 841 * <p> |
833 * undefined. | 842 * If both maximum significant digits and maximum integer/fraction digits ar
e set at the same time, |
834 * | 843 * the behavior is undefined. |
835 * <p> | 844 * |
836 * The number of significant digits can be specified in a pattern string usi
ng the '@' character. For example, the | 845 * <p> |
837 * pattern "@@#" corresponds to a minimum of 2 and a maximum of 3 significan
t digits. | 846 * The number of significant digits can be specified in a pattern string usi
ng the '@' character. For |
| 847 * example, the pattern "@@#" corresponds to a minimum of 2 and a maximum of
3 significant digits. |
838 * | 848 * |
839 * @param maximumSignificantDigits | 849 * @param maximumSignificantDigits |
840 * The maximum number of significant digits to display. | 850 * The maximum number of significant digits to display. |
841 * @return The property bag, for chaining. | 851 * @return The property bag, for chaining. |
842 */ | 852 */ |
843 public DecimalFormatProperties setMaximumSignificantDigits(int maximumSignif
icantDigits) { | 853 public DecimalFormatProperties setMaximumSignificantDigits(int maximumSignif
icantDigits) { |
844 this.maximumSignificantDigits = maximumSignificantDigits; | 854 this.maximumSignificantDigits = maximumSignificantDigits; |
845 return this; | 855 return this; |
846 } | 856 } |
847 | 857 |
848 /** | 858 /** |
849 * Sets the minimum number of digits to display in the exponent. For example
, the number "1200" with the pattern | 859 * Sets the minimum number of digits to display in the exponent. For example
, the number "1200" with |
850 * "0.0E00", which has 2 exponent digits, would be formatted as "1.2E03" in
<em>en-US</em>. | 860 * the pattern "0.0E00", which has 2 exponent digits, would be formatted as
"1.2E03" in |
| 861 * <em>en-US</em>. |
851 * | 862 * |
852 * @param minimumExponentDigits | 863 * @param minimumExponentDigits |
853 * The minimum number of digits to display in the exponent field. | 864 * The minimum number of digits to display in the exponent field. |
854 * @return The property bag, for chaining. | 865 * @return The property bag, for chaining. |
855 */ | 866 */ |
856 public DecimalFormatProperties setMinimumExponentDigits(int minimumExponentD
igits) { | 867 public DecimalFormatProperties setMinimumExponentDigits(int minimumExponentD
igits) { |
857 this.minimumExponentDigits = minimumExponentDigits; | 868 this.minimumExponentDigits = minimumExponentDigits; |
858 return this; | 869 return this; |
859 } | 870 } |
860 | 871 |
861 /** | 872 /** |
862 * Sets the minimum number of digits to display after the decimal point. If
the number has fewer than this number of | 873 * Sets the minimum number of digits to display after the decimal point. If
the number has fewer than |
863 * digits, the number will be padded with zeros. The pattern "#00.0#", for e
xample, corresponds to 1 minimum | 874 * this number of digits, the number will be padded with zeros. The pattern
"#00.0#", for example, |
864 * fraction digit, and the number 456 would be formatted as "456.0" in local
e <em>en-US</em>. | 875 * corresponds to 1 minimum fraction digit, and the number 456 would be form
atted as "456.0" in |
| 876 * locale <em>en-US</em>. |
865 * | 877 * |
866 * @param minimumFractionDigits | 878 * @param minimumFractionDigits |
867 * The minimum number of fraction digits to output. | 879 * The minimum number of fraction digits to output. |
868 * @return The property bag, for chaining. | 880 * @return The property bag, for chaining. |
869 */ | 881 */ |
870 public DecimalFormatProperties setMinimumFractionDigits(int minimumFractionD
igits) { | 882 public DecimalFormatProperties setMinimumFractionDigits(int minimumFractionD
igits) { |
871 this.minimumFractionDigits = minimumFractionDigits; | 883 this.minimumFractionDigits = minimumFractionDigits; |
872 return this; | 884 return this; |
873 } | 885 } |
874 | 886 |
875 /** | 887 /** |
876 * Sets the minimum number of digits required to be beyond the first groupin
g separator in order to enable grouping. | 888 * Sets the minimum number of digits required to be beyond the first groupin
g separator in order to |
877 * For example, if the minimum grouping digits is 2, then 1234 would be form
atted as "1234" but 12345 would be | 889 * enable grouping. For example, if the minimum grouping digits is 2, then 1
234 would be formatted as |
878 * formatted as "12,345" in <em>en-US</em>. Note that 1234567 would still be
formatted as "1,234,567", not | 890 * "1234" but 12345 would be formatted as "12,345" in <em>en-US</em>. Note t
hat 1234567 would still |
879 * "1234,567". | 891 * be formatted as "1,234,567", not "1234,567". |
880 * | 892 * |
881 * @param minimumGroupingDigits | 893 * @param minimumGroupingDigits |
882 * How many digits must appear before a grouping separator before
enabling grouping. | 894 * How many digits must appear before a grouping separator before
enabling grouping. |
883 * @return The property bag, for chaining. | 895 * @return The property bag, for chaining. |
884 */ | 896 */ |
885 public DecimalFormatProperties setMinimumGroupingDigits(int minimumGroupingD
igits) { | 897 public DecimalFormatProperties setMinimumGroupingDigits(int minimumGroupingD
igits) { |
886 this.minimumGroupingDigits = minimumGroupingDigits; | 898 this.minimumGroupingDigits = minimumGroupingDigits; |
887 return this; | 899 return this; |
888 } | 900 } |
889 | 901 |
890 /** | 902 /** |
891 * Sets the minimum number of digits to display before the decimal point. If
the number has fewer than this number | 903 * Sets the minimum number of digits to display before the decimal point. If
the number has fewer |
892 * of digits, the number will be padded with zeros. The pattern "#00.0#", fo
r example, corresponds to 2 minimum | 904 * than this number of digits, the number will be padded with zeros. The pat
tern "#00.0#", for |
893 * integer digits, and the number 5.3 would be formatted as "05.3" in locale
<em>en-US</em>. | 905 * example, corresponds to 2 minimum integer digits, and the number 5.3 woul
d be formatted as "05.3" |
| 906 * in locale <em>en-US</em>. |
894 * | 907 * |
895 * @param minimumIntegerDigits | 908 * @param minimumIntegerDigits |
896 * The minimum number of integer digits to output. | 909 * The minimum number of integer digits to output. |
897 * @return The property bag, for chaining. | 910 * @return The property bag, for chaining. |
898 */ | 911 */ |
899 public DecimalFormatProperties setMinimumIntegerDigits(int minimumIntegerDig
its) { | 912 public DecimalFormatProperties setMinimumIntegerDigits(int minimumIntegerDig
its) { |
900 this.minimumIntegerDigits = minimumIntegerDigits; | 913 this.minimumIntegerDigits = minimumIntegerDigits; |
901 return this; | 914 return this; |
902 } | 915 } |
903 | 916 |
904 /** | 917 /** |
905 * Sets the minimum number of significant digits to display. If, after round
ing to the number of significant digits | 918 * Sets the minimum number of significant digits to display. If, after round
ing to the number of |
906 * specified by {@link #setMaximumSignificantDigits}, the number of remainin
g significant digits is less than the | 919 * significant digits specified by {@link #setMaximumSignificantDigits}, the
number of remaining |
907 * minimum, the number will be padded with zeros. For example, if minimum si
gnificant digits is 3, the number 5.8 | 920 * significant digits is less than the minimum, the number will be padded wi
th zeros. For example, if |
908 * will be formatted as "5.80" in locale <em>en-US</em>. Note that minimum s
ignificant digits is relevant only when | 921 * minimum significant digits is 3, the number 5.8 will be formatted as "5.8
0" in locale |
909 * numbers have digits after the decimal point. | 922 * <em>en-US</em>. Note that minimum significant digits is relevant only whe
n numbers have digits |
910 * | 923 * after the decimal point. |
911 * <p> | 924 * |
912 * If both minimum significant digits and minimum integer/fraction digits ar
e set at the same time, both values will | 925 * <p> |
913 * be respected, and the one that results in the greater number of padding z
eros will be used. For example, | 926 * If both minimum significant digits and minimum integer/fraction digits ar
e set at the same time, |
914 * formatting the number 73 with 3 minimum significant digits and 2 minimum
fraction digits will produce "73.00". | 927 * both values will be respected, and the one that results in the greater nu
mber of padding zeros |
915 * | 928 * will be used. For example, formatting the number 73 with 3 minimum signif
icant digits and 2 |
916 * <p> | 929 * minimum fraction digits will produce "73.00". |
917 * The number of significant digits can be specified in a pattern string usi
ng the '@' character. For example, the | 930 * |
918 * pattern "@@#" corresponds to a minimum of 2 and a maximum of 3 significan
t digits. | 931 * <p> |
| 932 * The number of significant digits can be specified in a pattern string usi
ng the '@' character. For |
| 933 * example, the pattern "@@#" corresponds to a minimum of 2 and a maximum of
3 significant digits. |
919 * | 934 * |
920 * @param minimumSignificantDigits | 935 * @param minimumSignificantDigits |
921 * The minimum number of significant digits to display. | 936 * The minimum number of significant digits to display. |
922 * @return The property bag, for chaining. | 937 * @return The property bag, for chaining. |
923 */ | 938 */ |
924 public DecimalFormatProperties setMinimumSignificantDigits(int minimumSignif
icantDigits) { | 939 public DecimalFormatProperties setMinimumSignificantDigits(int minimumSignif
icantDigits) { |
925 this.minimumSignificantDigits = minimumSignificantDigits; | 940 this.minimumSignificantDigits = minimumSignificantDigits; |
926 return this; | 941 return this; |
927 } | 942 } |
928 | 943 |
929 /** | 944 /** |
930 * Multiply all numbers by this amount before formatting. | 945 * Multiply all numbers by this amount before formatting. |
931 * | 946 * |
932 * @param multiplier | 947 * @param multiplier |
933 * The amount to multiply by. | 948 * The amount to multiply by. |
934 * @return The property bag, for chaining. | 949 * @return The property bag, for chaining. |
935 * @see #setMagnitudeMultiplier | 950 * @see #setMagnitudeMultiplier |
936 */ | 951 */ |
937 public DecimalFormatProperties setMultiplier(BigDecimal multiplier) { | 952 public DecimalFormatProperties setMultiplier(BigDecimal multiplier) { |
938 this.multiplier = multiplier; | 953 this.multiplier = multiplier; |
939 return this; | 954 return this; |
940 } | 955 } |
941 | 956 |
942 /** | 957 /** |
943 * Sets the prefix to prepend to negative numbers. The prefix will be interp
reted literally. For example, if you set | 958 * Sets the prefix to prepend to negative numbers. The prefix will be interp
reted literally. For |
944 * a negative prefix of <code>n</code>, then the number -123 will be formatt
ed as "n123" in the locale | 959 * example, if you set a negative prefix of <code>n</code>, then the number
-123 will be formatted as |
945 * <em>en-US</em>. Note that if the negative prefix is left unset, the local
e's minus sign is used. | 960 * "n123" in the locale <em>en-US</em>. Note that if the negative prefix is
left unset, the locale's |
| 961 * minus sign is used. |
946 * | 962 * |
947 * <p> | 963 * <p> |
948 * For more information on prefixes and suffixes, see {@link MutablePatternM
odifier}. | 964 * For more information on prefixes and suffixes, see {@link MutablePatternM
odifier}. |
949 * | 965 * |
950 * @param negativePrefix | 966 * @param negativePrefix |
951 * The CharSequence to prepend to negative numbers. | 967 * The CharSequence to prepend to negative numbers. |
952 * @return The property bag, for chaining. | 968 * @return The property bag, for chaining. |
953 * @see #setNegativePrefixPattern | 969 * @see #setNegativePrefixPattern |
954 */ | 970 */ |
955 public DecimalFormatProperties setNegativePrefix(String negativePrefix) { | 971 public DecimalFormatProperties setNegativePrefix(String negativePrefix) { |
956 this.negativePrefix = negativePrefix; | 972 this.negativePrefix = negativePrefix; |
957 return this; | 973 return this; |
958 } | 974 } |
959 | 975 |
960 /** | 976 /** |
961 * Sets the prefix to prepend to negative numbers. Locale-specific symbols w
ill be substituted into the string | 977 * Sets the prefix to prepend to negative numbers. Locale-specific symbols w
ill be substituted into |
962 * according to Unicode Technical Standard #35 (LDML). | 978 * the string according to Unicode Technical Standard #35 (LDML). |
963 * | 979 * |
964 * <p> | 980 * <p> |
965 * For more information on prefixes and suffixes, see {@link MutablePatternM
odifier}. | 981 * For more information on prefixes and suffixes, see {@link MutablePatternM
odifier}. |
966 * | 982 * |
967 * @param negativePrefixPattern | 983 * @param negativePrefixPattern |
968 * The CharSequence to prepend to negative numbers after locale s
ymbol substitutions take place. | 984 * The CharSequence to prepend to negative numbers after locale s
ymbol substitutions take |
| 985 * place. |
969 * @return The property bag, for chaining. | 986 * @return The property bag, for chaining. |
970 * @see #setNegativePrefix | 987 * @see #setNegativePrefix |
971 */ | 988 */ |
972 public DecimalFormatProperties setNegativePrefixPattern(String negativePrefi
xPattern) { | 989 public DecimalFormatProperties setNegativePrefixPattern(String negativePrefi
xPattern) { |
973 this.negativePrefixPattern = negativePrefixPattern; | 990 this.negativePrefixPattern = negativePrefixPattern; |
974 return this; | 991 return this; |
975 } | 992 } |
976 | 993 |
977 /** | 994 /** |
978 * Sets the suffix to append to negative numbers. The suffix will be interpr
eted literally. For example, if you set | 995 * Sets the suffix to append to negative numbers. The suffix will be interpr
eted literally. For |
979 * a suffix prefix of <code>n</code>, then the number -123 will be formatted
as "-123n" in the locale | 996 * example, if you set a suffix prefix of <code>n</code>, then the number -1
23 will be formatted as |
980 * <em>en-US</em>. Note that the minus sign is prepended by default unless o
therwise specified in either the pattern | 997 * "-123n" in the locale <em>en-US</em>. Note that the minus sign is prepend
ed by default unless |
981 * string or in one of the {@link #setNegativePrefix} methods. | 998 * otherwise specified in either the pattern string or in one of the {@link
#setNegativePrefix} |
| 999 * methods. |
982 * | 1000 * |
983 * <p> | 1001 * <p> |
984 * For more information on prefixes and suffixes, see {@link MutablePatternM
odifier}. | 1002 * For more information on prefixes and suffixes, see {@link MutablePatternM
odifier}. |
985 * | 1003 * |
986 * @param negativeSuffix | 1004 * @param negativeSuffix |
987 * The CharSequence to append to negative numbers. | 1005 * The CharSequence to append to negative numbers. |
988 * @return The property bag, for chaining. | 1006 * @return The property bag, for chaining. |
989 * @see #setNegativeSuffixPattern | 1007 * @see #setNegativeSuffixPattern |
990 */ | 1008 */ |
991 public DecimalFormatProperties setNegativeSuffix(String negativeSuffix) { | 1009 public DecimalFormatProperties setNegativeSuffix(String negativeSuffix) { |
992 this.negativeSuffix = negativeSuffix; | 1010 this.negativeSuffix = negativeSuffix; |
993 return this; | 1011 return this; |
994 } | 1012 } |
995 | 1013 |
996 /** | 1014 /** |
997 * Sets the suffix to append to negative numbers. Locale-specific symbols wi
ll be substituted into the string | 1015 * Sets the suffix to append to negative numbers. Locale-specific symbols wi
ll be substituted into |
998 * according to Unicode Technical Standard #35 (LDML). | 1016 * the string according to Unicode Technical Standard #35 (LDML). |
999 * | 1017 * |
1000 * <p> | 1018 * <p> |
1001 * For more information on prefixes and suffixes, see {@link MutablePatternM
odifier}. | 1019 * For more information on prefixes and suffixes, see {@link MutablePatternM
odifier}. |
1002 * | 1020 * |
1003 * @param negativeSuffixPattern | 1021 * @param negativeSuffixPattern |
1004 * The CharSequence to append to negative numbers after locale sy
mbol substitutions take place. | 1022 * The CharSequence to append to negative numbers after locale sy
mbol substitutions take |
| 1023 * place. |
1005 * @return The property bag, for chaining. | 1024 * @return The property bag, for chaining. |
1006 * @see #setNegativeSuffix | 1025 * @see #setNegativeSuffix |
1007 */ | 1026 */ |
1008 public DecimalFormatProperties setNegativeSuffixPattern(String negativeSuffi
xPattern) { | 1027 public DecimalFormatProperties setNegativeSuffixPattern(String negativeSuffi
xPattern) { |
1009 this.negativeSuffixPattern = negativeSuffixPattern; | 1028 this.negativeSuffixPattern = negativeSuffixPattern; |
1010 return this; | 1029 return this; |
1011 } | 1030 } |
1012 | 1031 |
1013 /** | 1032 /** |
1014 * Sets the location where the padding string is to be inserted to maintain
the padding width: one of BEFORE_PREFIX, | 1033 * Sets the location where the padding string is to be inserted to maintain
the padding width: one of |
1015 * AFTER_PREFIX, BEFORE_SUFFIX, or AFTER_SUFFIX. | 1034 * BEFORE_PREFIX, AFTER_PREFIX, BEFORE_SUFFIX, or AFTER_SUFFIX. |
1016 * | 1035 * |
1017 * <p> | 1036 * <p> |
1018 * Must be used in conjunction with {@link #setFormatWidth}. | 1037 * Must be used in conjunction with {@link #setFormatWidth}. |
1019 * | 1038 * |
1020 * @param paddingLocation | 1039 * @param paddingLocation |
1021 * The output width. | 1040 * The output width. |
1022 * @return The property bag, for chaining. | 1041 * @return The property bag, for chaining. |
1023 * @see #setFormatWidth | 1042 * @see #setFormatWidth |
1024 */ | 1043 */ |
1025 public DecimalFormatProperties setPadPosition(PadPosition paddingLocation) { | 1044 public DecimalFormatProperties setPadPosition(PadPosition paddingLocation) { |
1026 this.padPosition = paddingLocation; | 1045 this.padPosition = paddingLocation; |
1027 return this; | 1046 return this; |
1028 } | 1047 } |
1029 | 1048 |
1030 /** | 1049 /** |
1031 * Sets the string used for padding. The string should contain a single char
acter or grapheme cluster. | 1050 * Sets the string used for padding. The string should contain a single char
acter or grapheme |
| 1051 * cluster. |
1032 * | 1052 * |
1033 * <p> | 1053 * <p> |
1034 * Must be used in conjunction with {@link #setFormatWidth}. | 1054 * Must be used in conjunction with {@link #setFormatWidth}. |
1035 * | 1055 * |
1036 * @param paddingString | 1056 * @param paddingString |
1037 * The padding string. Defaults to an ASCII space (U+0020). | 1057 * The padding string. Defaults to an ASCII space (U+0020). |
1038 * @return The property bag, for chaining. | 1058 * @return The property bag, for chaining. |
1039 * @see #setFormatWidth | 1059 * @see #setFormatWidth |
1040 */ | 1060 */ |
1041 public DecimalFormatProperties setPadString(String paddingString) { | 1061 public DecimalFormatProperties setPadString(String paddingString) { |
1042 this.padString = paddingString; | 1062 this.padString = paddingString; |
1043 return this; | 1063 return this; |
1044 } | 1064 } |
1045 | 1065 |
1046 /** | 1066 /** |
1047 * Whether to require cases to match when parsing strings; default is true.
Case sensitivity applies to prefixes, | 1067 * Whether to require cases to match when parsing strings; default is true.
Case sensitivity applies |
1048 * suffixes, the exponent separator, the symbol "NaN", and the infinity symb
ol. Grouping separators, decimal | 1068 * to prefixes, suffixes, the exponent separator, the symbol "NaN", and the
infinity symbol. Grouping |
1049 * separators, and padding are always case-sensitive. Currencies are always
case-insensitive. | 1069 * separators, decimal separators, and padding are always case-sensitive. Cu
rrencies are always |
1050 * | 1070 * case-insensitive. |
1051 * <p> | 1071 * |
1052 * This setting is ignored in fast mode. In fast mode, strings are always co
mpared in a case-sensitive way. | 1072 * <p> |
| 1073 * This setting is ignored in fast mode. In fast mode, strings are always co
mpared in a |
| 1074 * case-sensitive way. |
1053 * | 1075 * |
1054 * @param parseCaseSensitive | 1076 * @param parseCaseSensitive |
1055 * true to be case-sensitive when parsing; false to allow any cas
e. | 1077 * true to be case-sensitive when parsing; false to allow any cas
e. |
1056 * @return The property bag, for chaining. | 1078 * @return The property bag, for chaining. |
1057 */ | 1079 */ |
1058 public DecimalFormatProperties setParseCaseSensitive(boolean parseCaseSensit
ive) { | 1080 public DecimalFormatProperties setParseCaseSensitive(boolean parseCaseSensit
ive) { |
1059 this.parseCaseSensitive = parseCaseSensitive; | 1081 this.parseCaseSensitive = parseCaseSensitive; |
1060 return this; | 1082 return this; |
1061 } | 1083 } |
1062 | 1084 |
1063 /** | 1085 /** |
1064 * Sets the strategy used during parsing when a code point needs to be inter
preted as either a decimal separator or | 1086 * Sets the strategy used during parsing when a code point needs to be inter
preted as either a |
1065 * a grouping separator. | 1087 * decimal separator or a grouping separator. |
1066 * | 1088 * |
1067 * <p> | 1089 * <p> |
1068 * The comma, period, space, and apostrophe have different meanings in diffe
rent locales. For example, in | 1090 * The comma, period, space, and apostrophe have different meanings in diffe
rent locales. For |
1069 * <em>en-US</em> and most American locales, the period is used as a decimal
separator, but in <em>es-PY</em> and | 1091 * example, in <em>en-US</em> and most American locales, the period is used
as a decimal separator, |
1070 * most European locales, it is used as a grouping separator. | 1092 * but in <em>es-PY</em> and most European locales, it is used as a grouping
separator. |
1071 * | 1093 * |
1072 * <p> | 1094 * <p> |
1073 * Suppose you are in <em>fr-FR</em> the parser encounters the string "1.234
". In <em>fr-FR</em>, the grouping is a | 1095 * Suppose you are in <em>fr-FR</em> the parser encounters the string "1.234
". In <em>fr-FR</em>, the |
1074 * space and the decimal is a comma. The <em>grouping mode</em> is a mechani
sm to let you specify whether to accept | 1096 * grouping is a space and the decimal is a comma. The <em>grouping mode</em
> is a mechanism to let |
1075 * the string as 1234 (GroupingMode.DEFAULT) or whether to reject it since t
he separators don't match | 1097 * you specify whether to accept the string as 1234 (GroupingMode.DEFAULT) o
r whether to reject it |
1076 * (GroupingMode.RESTRICTED). | 1098 * since the separators don't match (GroupingMode.RESTRICTED). |
1077 * | 1099 * |
1078 * <p> | 1100 * <p> |
1079 * When resolving grouping separators, it is the <em>equivalence class</em>
of separators that is considered. For | 1101 * When resolving grouping separators, it is the <em>equivalence class</em>
of separators that is |
1080 * example, a period is seen as equal to a fixed set of other period-like ch
aracters. | 1102 * considered. For example, a period is seen as equal to a fixed set of othe
r period-like characters. |
1081 * | 1103 * |
1082 * @param parseGroupingMode | 1104 * @param parseGroupingMode |
1083 * The {@link GroupingMode} to use; either DEFAULT or RESTRICTED. | 1105 * The {@link GroupingMode} to use; either DEFAULT or RESTRICTED. |
1084 * @return The property bag, for chaining. | 1106 * @return The property bag, for chaining. |
1085 */ | 1107 */ |
1086 public DecimalFormatProperties setParseGroupingMode(GroupingMode parseGroupi
ngMode) { | 1108 public DecimalFormatProperties setParseGroupingMode(GroupingMode parseGroupi
ngMode) { |
1087 this.parseGroupingMode = parseGroupingMode; | 1109 this.parseGroupingMode = parseGroupingMode; |
1088 return this; | 1110 return this; |
1089 } | 1111 } |
1090 | 1112 |
1091 /** | 1113 /** |
1092 * Whether to ignore the fractional part of numbers. For example, parses "12
3.4" to "123" instead of "123.4". | 1114 * Whether to ignore the fractional part of numbers. For example, parses "12
3.4" to "123" instead of |
| 1115 * "123.4". |
1093 * | 1116 * |
1094 * @param parseIntegerOnly | 1117 * @param parseIntegerOnly |
1095 * true to parse integers only; false to parse integers with thei
r fraction parts | 1118 * true to parse integers only; false to parse integers with thei
r fraction parts |
1096 * @return The property bag, for chaining. | 1119 * @return The property bag, for chaining. |
1097 */ | 1120 */ |
1098 public DecimalFormatProperties setParseIntegerOnly(boolean parseIntegerOnly)
{ | 1121 public DecimalFormatProperties setParseIntegerOnly(boolean parseIntegerOnly)
{ |
1099 this.parseIntegerOnly = parseIntegerOnly; | 1122 this.parseIntegerOnly = parseIntegerOnly; |
1100 return this; | 1123 return this; |
1101 } | 1124 } |
1102 | 1125 |
1103 /** | 1126 /** |
1104 * Controls certain rules for how strict this parser is when reading strings
. See {@link ParseMode#LENIENT} and | 1127 * Controls certain rules for how strict this parser is when reading strings
. See |
1105 * {@link ParseMode#STRICT}. | 1128 * {@link ParseMode#LENIENT} and {@link ParseMode#STRICT}. |
1106 * | 1129 * |
1107 * @param parseMode | 1130 * @param parseMode |
1108 * Either {@link ParseMode#LENIENT} or {@link ParseMode#STRICT}. | 1131 * Either {@link ParseMode#LENIENT} or {@link ParseMode#STRICT}. |
1109 * @return The property bag, for chaining. | 1132 * @return The property bag, for chaining. |
1110 */ | 1133 */ |
1111 public DecimalFormatProperties setParseMode(ParseMode parseMode) { | 1134 public DecimalFormatProperties setParseMode(ParseMode parseMode) { |
1112 this.parseMode = parseMode; | 1135 this.parseMode = parseMode; |
1113 return this; | 1136 return this; |
1114 } | 1137 } |
1115 | 1138 |
1116 /** | 1139 /** |
1117 * Whether to ignore the exponential part of numbers. For example, parses "1
23E4" to "123" instead of "1230000". | 1140 * Whether to ignore the exponential part of numbers. For example, parses "1
23E4" to "123" instead of |
| 1141 * "1230000". |
1118 * | 1142 * |
1119 * @param parseNoExponent | 1143 * @param parseNoExponent |
1120 * true to ignore exponents; false to parse them. | 1144 * true to ignore exponents; false to parse them. |
1121 * @return The property bag, for chaining. | 1145 * @return The property bag, for chaining. |
1122 */ | 1146 */ |
1123 public DecimalFormatProperties setParseNoExponent(boolean parseNoExponent) { | 1147 public DecimalFormatProperties setParseNoExponent(boolean parseNoExponent) { |
1124 this.parseNoExponent = parseNoExponent; | 1148 this.parseNoExponent = parseNoExponent; |
1125 return this; | 1149 return this; |
1126 } | 1150 } |
1127 | 1151 |
1128 /** | 1152 /** |
1129 * Whether to always return a BigDecimal from {@link Parse#parse} and all ot
her parse methods. By default, a Long or | 1153 * Whether to always return a BigDecimal from {@link Parse#parse} and all ot
her parse methods. By |
1130 * a BigInteger are returned when possible. | 1154 * default, a Long or a BigInteger are returned when possible. |
1131 * | 1155 * |
1132 * @param parseToBigDecimal | 1156 * @param parseToBigDecimal |
1133 * true to always return a BigDecimal; false to return a Long or
a BigInteger when possible. | 1157 * true to always return a BigDecimal; false to return a Long or
a BigInteger when |
| 1158 * possible. |
1134 * @return The property bag, for chaining. | 1159 * @return The property bag, for chaining. |
1135 */ | 1160 */ |
1136 public DecimalFormatProperties setParseToBigDecimal(boolean parseToBigDecima
l) { | 1161 public DecimalFormatProperties setParseToBigDecimal(boolean parseToBigDecima
l) { |
1137 this.parseToBigDecimal = parseToBigDecimal; | 1162 this.parseToBigDecimal = parseToBigDecimal; |
1138 return this; | 1163 return this; |
1139 } | 1164 } |
1140 | 1165 |
1141 /** | 1166 /** |
1142 * Sets the PluralRules object to use instead of the default for the locale. | 1167 * Sets the PluralRules object to use instead of the default for the locale. |
1143 * | 1168 * |
1144 * @param pluralRules | 1169 * @param pluralRules |
1145 * The object to reference. | 1170 * The object to reference. |
1146 * @return The property bag, for chaining. | 1171 * @return The property bag, for chaining. |
1147 */ | 1172 */ |
1148 public DecimalFormatProperties setPluralRules(PluralRules pluralRules) { | 1173 public DecimalFormatProperties setPluralRules(PluralRules pluralRules) { |
1149 this.pluralRules = pluralRules; | 1174 this.pluralRules = pluralRules; |
1150 return this; | 1175 return this; |
1151 } | 1176 } |
1152 | 1177 |
1153 /** | 1178 /** |
1154 * Sets the prefix to prepend to positive numbers. The prefix will be interp
reted literally. For example, if you set | 1179 * Sets the prefix to prepend to positive numbers. The prefix will be interp
reted literally. For |
1155 * a positive prefix of <code>p</code>, then the number 123 will be formatte
d as "p123" in the locale | 1180 * example, if you set a positive prefix of <code>p</code>, then the number
123 will be formatted as |
1156 * <em>en-US</em>. | 1181 * "p123" in the locale <em>en-US</em>. |
1157 * | 1182 * |
1158 * <p> | 1183 * <p> |
1159 * For more information on prefixes and suffixes, see {@link MutablePatternM
odifier}. | 1184 * For more information on prefixes and suffixes, see {@link MutablePatternM
odifier}. |
1160 * | 1185 * |
1161 * @param positivePrefix | 1186 * @param positivePrefix |
1162 * The CharSequence to prepend to positive numbers. | 1187 * The CharSequence to prepend to positive numbers. |
1163 * @return The property bag, for chaining. | 1188 * @return The property bag, for chaining. |
1164 * @see #setPositivePrefixPattern | 1189 * @see #setPositivePrefixPattern |
1165 */ | 1190 */ |
1166 public DecimalFormatProperties setPositivePrefix(String positivePrefix) { | 1191 public DecimalFormatProperties setPositivePrefix(String positivePrefix) { |
1167 this.positivePrefix = positivePrefix; | 1192 this.positivePrefix = positivePrefix; |
1168 return this; | 1193 return this; |
1169 } | 1194 } |
1170 | 1195 |
1171 /** | 1196 /** |
1172 * Sets the prefix to prepend to positive numbers. Locale-specific symbols w
ill be substituted into the string | 1197 * Sets the prefix to prepend to positive numbers. Locale-specific symbols w
ill be substituted into |
1173 * according to Unicode Technical Standard #35 (LDML). | 1198 * the string according to Unicode Technical Standard #35 (LDML). |
1174 * | 1199 * |
1175 * <p> | 1200 * <p> |
1176 * For more information on prefixes and suffixes, see {@link MutablePatternM
odifier}. | 1201 * For more information on prefixes and suffixes, see {@link MutablePatternM
odifier}. |
1177 * | 1202 * |
1178 * @param positivePrefixPattern | 1203 * @param positivePrefixPattern |
1179 * The CharSequence to prepend to positive numbers after locale s
ymbol substitutions take place. | 1204 * The CharSequence to prepend to positive numbers after locale s
ymbol substitutions take |
| 1205 * place. |
1180 * @return The property bag, for chaining. | 1206 * @return The property bag, for chaining. |
1181 * @see #setPositivePrefix | 1207 * @see #setPositivePrefix |
1182 */ | 1208 */ |
1183 public DecimalFormatProperties setPositivePrefixPattern(String positivePrefi
xPattern) { | 1209 public DecimalFormatProperties setPositivePrefixPattern(String positivePrefi
xPattern) { |
1184 this.positivePrefixPattern = positivePrefixPattern; | 1210 this.positivePrefixPattern = positivePrefixPattern; |
1185 return this; | 1211 return this; |
1186 } | 1212 } |
1187 | 1213 |
1188 /** | 1214 /** |
1189 * Sets the suffix to append to positive numbers. The suffix will be interpr
eted literally. For example, if you set | 1215 * Sets the suffix to append to positive numbers. The suffix will be interpr
eted literally. For |
1190 * a positive suffix of <code>p</code>, then the number 123 will be formatte
d as "123p" in the locale | 1216 * example, if you set a positive suffix of <code>p</code>, then the number
123 will be formatted as |
1191 * <em>en-US</em>. | 1217 * "123p" in the locale <em>en-US</em>. |
1192 * | 1218 * |
1193 * <p> | 1219 * <p> |
1194 * For more information on prefixes and suffixes, see {@link MutablePatternM
odifier}. | 1220 * For more information on prefixes and suffixes, see {@link MutablePatternM
odifier}. |
1195 * | 1221 * |
1196 * @param positiveSuffix | 1222 * @param positiveSuffix |
1197 * The CharSequence to append to positive numbers. | 1223 * The CharSequence to append to positive numbers. |
1198 * @return The property bag, for chaining. | 1224 * @return The property bag, for chaining. |
1199 * @see #setPositiveSuffixPattern | 1225 * @see #setPositiveSuffixPattern |
1200 */ | 1226 */ |
1201 public DecimalFormatProperties setPositiveSuffix(String positiveSuffix) { | 1227 public DecimalFormatProperties setPositiveSuffix(String positiveSuffix) { |
1202 this.positiveSuffix = positiveSuffix; | 1228 this.positiveSuffix = positiveSuffix; |
1203 return this; | 1229 return this; |
1204 } | 1230 } |
1205 | 1231 |
1206 /** | 1232 /** |
1207 * Sets the suffix to append to positive numbers. Locale-specific symbols wi
ll be substituted into the string | 1233 * Sets the suffix to append to positive numbers. Locale-specific symbols wi
ll be substituted into |
1208 * according to Unicode Technical Standard #35 (LDML). | 1234 * the string according to Unicode Technical Standard #35 (LDML). |
1209 * | 1235 * |
1210 * <p> | 1236 * <p> |
1211 * For more information on prefixes and suffixes, see {@link MutablePatternM
odifier}. | 1237 * For more information on prefixes and suffixes, see {@link MutablePatternM
odifier}. |
1212 * | 1238 * |
1213 * @param positiveSuffixPattern | 1239 * @param positiveSuffixPattern |
1214 * The CharSequence to append to positive numbers after locale sy
mbol substitutions take place. | 1240 * The CharSequence to append to positive numbers after locale sy
mbol substitutions take |
| 1241 * place. |
1215 * @return The property bag, for chaining. | 1242 * @return The property bag, for chaining. |
1216 * @see #setPositiveSuffix | 1243 * @see #setPositiveSuffix |
1217 */ | 1244 */ |
1218 public DecimalFormatProperties setPositiveSuffixPattern(String positiveSuffi
xPattern) { | 1245 public DecimalFormatProperties setPositiveSuffixPattern(String positiveSuffi
xPattern) { |
1219 this.positiveSuffixPattern = positiveSuffixPattern; | 1246 this.positiveSuffixPattern = positiveSuffixPattern; |
1220 return this; | 1247 return this; |
1221 } | 1248 } |
1222 | 1249 |
1223 /** | 1250 /** |
1224 * Sets the increment to which to round numbers. For example, with a roundin
g interval of 0.05, the number 11.17 | 1251 * Sets the increment to which to round numbers. For example, with a roundin
g interval of 0.05, the |
1225 * would be formatted as "11.15" in locale <em>en-US</em> with the default r
ounding mode. | 1252 * number 11.17 would be formatted as "11.15" in locale <em>en-US</em> with
the default rounding |
| 1253 * mode. |
1226 * | 1254 * |
1227 * <p> | 1255 * <p> |
1228 * You can use either a rounding increment or significant digits, but not bo
th at the same time. | 1256 * You can use either a rounding increment or significant digits, but not bo
th at the same time. |
1229 * | 1257 * |
1230 * <p> | 1258 * <p> |
1231 * The rounding increment can be specified in a pattern string. For example,
the pattern "#,##0.05" corresponds to a | 1259 * The rounding increment can be specified in a pattern string. For example,
the pattern "#,##0.05" |
1232 * rounding interval of 0.05 with 1 minimum integer digit and a grouping siz
e of 3. | 1260 * corresponds to a rounding interval of 0.05 with 1 minimum integer digit a
nd a grouping size of 3. |
1233 * | 1261 * |
1234 * @param roundingIncrement | 1262 * @param roundingIncrement |
1235 * The interval to which to round. | 1263 * The interval to which to round. |
1236 * @return The property bag, for chaining. | 1264 * @return The property bag, for chaining. |
1237 */ | 1265 */ |
1238 public DecimalFormatProperties setRoundingIncrement(BigDecimal roundingIncre
ment) { | 1266 public DecimalFormatProperties setRoundingIncrement(BigDecimal roundingIncre
ment) { |
1239 this.roundingIncrement = roundingIncrement; | 1267 this.roundingIncrement = roundingIncrement; |
1240 return this; | 1268 return this; |
1241 } | 1269 } |
1242 | 1270 |
1243 /** | 1271 /** |
1244 * Sets the rounding mode, which determines under which conditions extra dec
imal places are rounded either up or | 1272 * Sets the rounding mode, which determines under which conditions extra dec
imal places are rounded |
1245 * down. See {@link RoundingMode} for details on the choices of rounding mod
e. The default if not set explicitly is | 1273 * either up or down. See {@link RoundingMode} for details on the choices of
rounding mode. The |
1246 * {@link RoundingMode#HALF_EVEN}. | 1274 * default if not set explicitly is {@link RoundingMode#HALF_EVEN}. |
1247 * | 1275 * |
1248 * <p> | 1276 * <p> |
1249 * This setting is ignored if {@link #setMathContext} is used. | 1277 * This setting is ignored if {@link #setMathContext} is used. |
1250 * | 1278 * |
1251 * @param roundingMode | 1279 * @param roundingMode |
1252 * The rounding mode to use when rounding is required. | 1280 * The rounding mode to use when rounding is required. |
1253 * @return The property bag, for chaining. | 1281 * @return The property bag, for chaining. |
1254 * @see RoundingMode | 1282 * @see RoundingMode |
1255 * @see #setMathContext | 1283 * @see #setMathContext |
1256 */ | 1284 */ |
1257 public DecimalFormatProperties setRoundingMode(RoundingMode roundingMode) { | 1285 public DecimalFormatProperties setRoundingMode(RoundingMode roundingMode) { |
1258 this.roundingMode = roundingMode; | 1286 this.roundingMode = roundingMode; |
1259 return this; | 1287 return this; |
1260 } | 1288 } |
1261 | 1289 |
1262 /** | 1290 /** |
1263 * Sets the number of digits between grouping separators higher than the lea
st-significant grouping separator. For | 1291 * Sets the number of digits between grouping separators higher than the lea
st-significant grouping |
1264 * example, the locale <em>hi</em> uses a primary grouping size of 3 and a s
econdary grouping size of 2, so the | 1292 * separator. For example, the locale <em>hi</em> uses a primary grouping si
ze of 3 and a secondary |
1265 * number 1234567 would be formatted as "12,34,567". | 1293 * grouping size of 2, so the number 1234567 would be formatted as "12,34,56
7". |
1266 * | 1294 * |
1267 * <p> | 1295 * <p> |
1268 * The two levels of grouping separators can be specified in the pattern str
ing. For example, the <em>hi</em> | 1296 * The two levels of grouping separators can be specified in the pattern str
ing. For example, the |
1269 * locale's default decimal format pattern is "#,##,##0.###". | 1297 * <em>hi</em> locale's default decimal format pattern is "#,##,##0.###". |
1270 * | 1298 * |
1271 * @param secondaryGroupingSize | 1299 * @param secondaryGroupingSize |
1272 * The secondary grouping size. | 1300 * The secondary grouping size. |
1273 * @return The property bag, for chaining. | 1301 * @return The property bag, for chaining. |
1274 */ | 1302 */ |
1275 public DecimalFormatProperties setSecondaryGroupingSize(int secondaryGroupin
gSize) { | 1303 public DecimalFormatProperties setSecondaryGroupingSize(int secondaryGroupin
gSize) { |
1276 this.secondaryGroupingSize = secondaryGroupingSize; | 1304 this.secondaryGroupingSize = secondaryGroupingSize; |
1277 return this; | 1305 return this; |
1278 } | 1306 } |
1279 | 1307 |
1280 /** | 1308 /** |
1281 * Sets whether to always display of a plus sign on positive numbers. | 1309 * Sets whether to always display of a plus sign on positive numbers. |
1282 * | 1310 * |
1283 * <p> | 1311 * <p> |
1284 * If the location of the negative sign is specified by the decimal format p
attern (or by the negative prefix/suffix | 1312 * If the location of the negative sign is specified by the decimal format p
attern (or by the |
1285 * pattern methods), a plus sign is substituted into that location, in accor
dance with Unicode Technical Standard | 1313 * negative prefix/suffix pattern methods), a plus sign is substituted into
that location, in |
1286 * #35 (LDML) section 3.2.1. Otherwise, the plus sign is prepended to the nu
mber. For example, if the decimal format | 1314 * accordance with Unicode Technical Standard #35 (LDML) section 3.2.1. Othe
rwise, the plus sign is |
1287 * pattern <code>#;#-</code> is used, then formatting 123 would result in "1
23+" in the locale <em>en-US</em>. | 1315 * prepended to the number. For example, if the decimal format pattern <code
>#;#-</code> is used, |
1288 * | 1316 * then formatting 123 would result in "123+" in the locale <em>en-US</em>. |
1289 * <p> | 1317 * |
1290 * This method should be used <em>instead of</em> setting the positive prefi
x/suffix. The behavior is undefined if | 1318 * <p> |
1291 * alwaysShowPlusSign is set but the positive prefix/suffix already contains
a plus sign. | 1319 * This method should be used <em>instead of</em> setting the positive prefi
x/suffix. The behavior is |
| 1320 * undefined if alwaysShowPlusSign is set but the positive prefix/suffix alr
eady contains a plus |
| 1321 * sign. |
1292 * | 1322 * |
1293 * @param signAlwaysShown | 1323 * @param signAlwaysShown |
1294 * Whether positive numbers should display a plus sign. | 1324 * Whether positive numbers should display a plus sign. |
1295 * @return The property bag, for chaining. | 1325 * @return The property bag, for chaining. |
1296 */ | 1326 */ |
1297 public DecimalFormatProperties setSignAlwaysShown(boolean signAlwaysShown) { | 1327 public DecimalFormatProperties setSignAlwaysShown(boolean signAlwaysShown) { |
1298 this.signAlwaysShown = signAlwaysShown; | 1328 this.signAlwaysShown = signAlwaysShown; |
1299 return this; | 1329 return this; |
1300 } | 1330 } |
1301 | 1331 |
1302 @Override | 1332 @Override |
1303 public String toString() { | 1333 public String toString() { |
1304 StringBuilder result = new StringBuilder(); | 1334 StringBuilder result = new StringBuilder(); |
1305 result.append("<Properties"); | 1335 result.append("<Properties"); |
1306 toStringBare(result); | 1336 toStringBare(result); |
1307 result.append(">"); | 1337 result.append(">"); |
1308 return result.toString(); | 1338 return result.toString(); |
1309 } | 1339 } |
1310 | 1340 |
1311 /** | 1341 /** |
1312 * Appends a string containing properties that differ from the default, but
without being surrounded by | 1342 * Appends a string containing properties that differ from the default, but
without being surrounded |
1313 * <Properties>. | 1343 * by <Properties>. |
1314 */ | 1344 */ |
1315 public void toStringBare(StringBuilder result) { | 1345 public void toStringBare(StringBuilder result) { |
1316 Field[] fields = DecimalFormatProperties.class.getDeclaredFields(); | 1346 Field[] fields = DecimalFormatProperties.class.getDeclaredFields(); |
1317 for (Field field : fields) { | 1347 for (Field field : fields) { |
1318 Object myValue, defaultValue; | 1348 Object myValue, defaultValue; |
1319 try { | 1349 try { |
1320 myValue = field.get(this); | 1350 myValue = field.get(this); |
1321 defaultValue = field.get(DEFAULT); | 1351 defaultValue = field.get(DEFAULT); |
1322 } catch (IllegalArgumentException e) { | 1352 } catch (IllegalArgumentException e) { |
1323 e.printStackTrace(); | 1353 e.printStackTrace(); |
1324 continue; | 1354 continue; |
1325 } catch (IllegalAccessException e) { | 1355 } catch (IllegalAccessException e) { |
1326 e.printStackTrace(); | 1356 e.printStackTrace(); |
1327 continue; | 1357 continue; |
1328 } | 1358 } |
1329 if (myValue == null && defaultValue == null) { | 1359 if (myValue == null && defaultValue == null) { |
1330 continue; | 1360 continue; |
1331 } else if (myValue == null || defaultValue == null) { | 1361 } else if (myValue == null || defaultValue == null) { |
1332 result.append(" " + field.getName() + ":" + myValue); | 1362 result.append(" " + field.getName() + ":" + myValue); |
1333 } else if (!myValue.equals(defaultValue)) { | 1363 } else if (!myValue.equals(defaultValue)) { |
1334 result.append(" " + field.getName() + ":" + myValue); | 1364 result.append(" " + field.getName() + ":" + myValue); |
1335 } | 1365 } |
1336 } | 1366 } |
1337 } | 1367 } |
1338 | 1368 |
1339 /** | 1369 /** |
1340 * Custom serialization: save fields along with their name, so that fields c
an be easily added in the future in any | 1370 * Custom serialization: save fields along with their name, so that fields c
an be easily added in the |
1341 * order. Only save fields that differ from their default value. | 1371 * future in any order. Only save fields that differ from their default valu
e. |
1342 */ | 1372 */ |
1343 private void writeObject(ObjectOutputStream oos) throws IOException { | 1373 private void writeObject(ObjectOutputStream oos) throws IOException { |
1344 writeObjectImpl(oos); | 1374 writeObjectImpl(oos); |
1345 } | 1375 } |
1346 | 1376 |
1347 /* package-private */ void writeObjectImpl(ObjectOutputStream oos) throws IO
Exception { | 1377 /* package-private */ void writeObjectImpl(ObjectOutputStream oos) throws IO
Exception { |
1348 oos.defaultWriteObject(); | 1378 oos.defaultWriteObject(); |
1349 | 1379 |
1350 // Extra int for possible future use | 1380 // Extra int for possible future use |
1351 oos.writeInt(0); | 1381 oos.writeInt(0); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1383 | 1413 |
1384 // 2) Write each field with its name and value | 1414 // 2) Write each field with its name and value |
1385 for (int i = 0; i < count; i++) { | 1415 for (int i = 0; i < count; i++) { |
1386 Field field = fieldsToSerialize.get(i); | 1416 Field field = fieldsToSerialize.get(i); |
1387 Object value = valuesToSerialize.get(i); | 1417 Object value = valuesToSerialize.get(i); |
1388 oos.writeObject(field.getName()); | 1418 oos.writeObject(field.getName()); |
1389 oos.writeObject(value); | 1419 oos.writeObject(value); |
1390 } | 1420 } |
1391 } | 1421 } |
1392 } | 1422 } |
LEFT | RIGHT |