Print this page
rev 5615 : 6336885: RFE: Locale Data Deployment Enhancements
4609153: Provide locale data for Indic locales
5104387: Support for gl_ES locale (galician language)
6337471: desktop/system locale preferences support
7056139: (cal) SPI support for locale-dependent Calendar parameters
7058206: Provide CalendarData SPI for week params and display field value names
7073852: Support multiple scripts for digits and decimal symbols per locale
7079560: [Fmt-Da] Context dependent month names support in SimpleDateFormat
7171324: getAvailableLocales() of locale sensitive services should return the actual availability of locales
7151414: (cal) Support calendar type identification
7168528: LocaleServiceProvider needs to be aware of Locale extensions
7171372: (cal) locale's default Calendar should be created if unknown calendar is specified
Summary: JEP 127: Improve Locale Data Packaging and Adopt Unicode CLDR Data (part 1 w/o Jigsaw. by Naoto Sato and Masayoshi Okutsu)

Split Close
Expand all
Collapse all
          --- old/src/share/classes/java/text/DecimalFormat.java
          +++ new/src/share/classes/java/text/DecimalFormat.java
   1    1  /*
   2      - * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
        2 + * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved.
   3    3   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4    4   *
   5    5   * This code is free software; you can redistribute it and/or modify it
   6    6   * under the terms of the GNU General Public License version 2 only, as
   7    7   * published by the Free Software Foundation.  Oracle designates this
   8    8   * particular file as subject to the "Classpath" exception as provided
   9    9   * by Oracle in the LICENSE file that accompanied this code.
  10   10   *
  11   11   * This code is distributed in the hope that it will be useful, but WITHOUT
  12   12   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
↓ open down ↓ 18 lines elided ↑ open up ↑
  31   31   * and owned by Taligent, Inc., a wholly-owned subsidiary of IBM. These
  32   32   * materials are provided under terms of a License Agreement between Taligent
  33   33   * and Sun. This technology is protected by multiple US and International
  34   34   * patents. This notice and attribution to Taligent may not be removed.
  35   35   *   Taligent is a registered trademark of Taligent, Inc.
  36   36   *
  37   37   */
  38   38  
  39   39  package java.text;
  40   40  
  41      -import java.io.InvalidObjectException;
  42   41  import java.io.IOException;
       42 +import java.io.InvalidObjectException;
  43   43  import java.io.ObjectInputStream;
  44   44  import java.math.BigDecimal;
  45   45  import java.math.BigInteger;
  46   46  import java.math.RoundingMode;
       47 +import java.text.spi.NumberFormatProvider;
  47   48  import java.util.ArrayList;
  48   49  import java.util.Currency;
  49   50  import java.util.Locale;
  50   51  import java.util.ResourceBundle;
  51   52  import java.util.concurrent.ConcurrentHashMap;
  52   53  import java.util.concurrent.ConcurrentMap;
  53   54  import java.util.concurrent.atomic.AtomicInteger;
  54   55  import java.util.concurrent.atomic.AtomicLong;
  55      -import sun.util.resources.LocaleData;
       56 +import sun.util.locale.provider.LocaleProviderAdapter;
  56   57  
  57   58  /**
  58   59   * <code>DecimalFormat</code> is a concrete subclass of
  59   60   * <code>NumberFormat</code> that formats decimal numbers. It has a variety of
  60   61   * features designed to make it possible to parse and format numbers in any
  61   62   * locale, including support for Western, Arabic, and Indic digits.  It also
  62   63   * supports different kinds of numbers, including integers (123), fixed-point
  63   64   * numbers (123.4), scientific notation (1.23E4), percentages (12%), and
  64   65   * currency amounts ($123).  All of these can be localized.
  65   66   *
↓ open down ↓ 325 lines elided ↑ open up ↑
 391  392       * @see java.text.NumberFormat#getNumberInstance
 392  393       * @see java.text.NumberFormat#getCurrencyInstance
 393  394       * @see java.text.NumberFormat#getPercentInstance
 394  395       */
 395  396      public DecimalFormat() {
 396  397          Locale def = Locale.getDefault(Locale.Category.FORMAT);
 397  398          // try to get the pattern from the cache
 398  399          String pattern = cachedLocaleData.get(def);
 399  400          if (pattern == null) {  /* cache miss */
 400  401              // Get the pattern for the default locale.
 401      -            ResourceBundle rb = LocaleData.getNumberFormatData(def);
      402 +            LocaleProviderAdapter adapter = LocaleProviderAdapter.getAdapter(NumberFormatProvider.class, def);
      403 +            switch (adapter.getAdapterType()) {
      404 +            case HOST:
      405 +            case SPI:
      406 +                adapter = LocaleProviderAdapter.getResourceBundleBased();
      407 +                break;
      408 +            }
      409 +            ResourceBundle rb = adapter.getLocaleData().getNumberFormatData(def);
 402  410              String[] all = rb.getStringArray("NumberPatterns");
 403  411              pattern = all[0];
 404  412              /* update cache */
 405  413              cachedLocaleData.putIfAbsent(def, pattern);
 406  414          }
 407  415  
 408  416          // Always applyPattern after the symbols are set
 409      -        this.symbols = new DecimalFormatSymbols(def);
      417 +        this.symbols = DecimalFormatSymbols.getInstance(def);
 410  418          applyPattern(pattern, false);
 411  419      }
 412  420  
 413  421  
 414  422      /**
 415  423       * Creates a DecimalFormat using the given pattern and the symbols
 416  424       * for the default locale. This is a convenient way to obtain a
 417  425       * DecimalFormat when internationalization is not the main concern.
 418  426       * <p>
 419  427       * To obtain standard formats for a given locale, use the factory methods
↓ open down ↓ 4 lines elided ↑ open up ↑
 424  432       * @param pattern A non-localized pattern string.
 425  433       * @exception NullPointerException if <code>pattern</code> is null
 426  434       * @exception IllegalArgumentException if the given pattern is invalid.
 427  435       * @see java.text.NumberFormat#getInstance
 428  436       * @see java.text.NumberFormat#getNumberInstance
 429  437       * @see java.text.NumberFormat#getCurrencyInstance
 430  438       * @see java.text.NumberFormat#getPercentInstance
 431  439       */
 432  440      public DecimalFormat(String pattern) {
 433  441          // Always applyPattern after the symbols are set
 434      -        this.symbols = new DecimalFormatSymbols(Locale.getDefault(Locale.Category.FORMAT));
      442 +        this.symbols = DecimalFormatSymbols.getInstance(Locale.getDefault(Locale.Category.FORMAT));
 435  443          applyPattern(pattern, false);
 436  444      }
 437  445  
 438  446  
 439  447      /**
 440  448       * Creates a DecimalFormat using the given pattern and symbols.
 441  449       * Use this constructor when you need to completely customize the
 442  450       * behavior of the format.
 443  451       * <p>
 444  452       * To obtain standard formats for a given
↓ open down ↓ 33 lines elided ↑ open up ↑
 478  486       *                   On output: the offsets of the alignment field.
 479  487       * @return           the value passed in as <code>toAppendTo</code>
 480  488       * @exception        IllegalArgumentException if <code>number</code> is
 481  489       *                   null or not an instance of <code>Number</code>.
 482  490       * @exception        NullPointerException if <code>toAppendTo</code> or
 483  491       *                   <code>pos</code> is null
 484  492       * @exception        ArithmeticException if rounding is needed with rounding
 485  493       *                   mode being set to RoundingMode.UNNECESSARY
 486  494       * @see              java.text.FieldPosition
 487  495       */
      496 +    @Override
 488  497      public final StringBuffer format(Object number,
 489  498                                       StringBuffer toAppendTo,
 490  499                                       FieldPosition pos) {
 491  500          if (number instanceof Long || number instanceof Integer ||
 492  501                     number instanceof Short || number instanceof Byte ||
 493  502                     number instanceof AtomicInteger ||
 494  503                     number instanceof AtomicLong ||
 495  504                     (number instanceof BigInteger &&
 496  505                      ((BigInteger)number).bitLength () < 64)) {
 497  506              return format(((Number)number).longValue(), toAppendTo, pos);
↓ open down ↓ 12 lines elided ↑ open up ↑
 510  519       * Formats a double to produce a string.
 511  520       * @param number    The double to format
 512  521       * @param result    where the text is to be appended
 513  522       * @param fieldPosition    On input: an alignment field, if desired.
 514  523       * On output: the offsets of the alignment field.
 515  524       * @exception ArithmeticException if rounding is needed with rounding
 516  525       *            mode being set to RoundingMode.UNNECESSARY
 517  526       * @return The formatted number string
 518  527       * @see java.text.FieldPosition
 519  528       */
      529 +    @Override
 520  530      public StringBuffer format(double number, StringBuffer result,
 521  531                                 FieldPosition fieldPosition) {
 522  532          fieldPosition.setBeginIndex(0);
 523  533          fieldPosition.setEndIndex(0);
 524  534  
 525  535          return format(number, result, fieldPosition.getFieldDelegate());
 526  536      }
 527  537  
 528  538      /**
 529  539       * Formats a double to produce a string.
↓ open down ↓ 81 lines elided ↑ open up ↑
 611  621       * Format a long to produce a string.
 612  622       * @param number    The long to format
 613  623       * @param result    where the text is to be appended
 614  624       * @param fieldPosition    On input: an alignment field, if desired.
 615  625       * On output: the offsets of the alignment field.
 616  626       * @exception       ArithmeticException if rounding is needed with rounding
 617  627       *                  mode being set to RoundingMode.UNNECESSARY
 618  628       * @return The formatted number string
 619  629       * @see java.text.FieldPosition
 620  630       */
      631 +    @Override
 621  632      public StringBuffer format(long number, StringBuffer result,
 622  633                                 FieldPosition fieldPosition) {
 623  634          fieldPosition.setBeginIndex(0);
 624  635          fieldPosition.setEndIndex(0);
 625  636  
 626  637          return format(number, result, fieldPosition.getFieldDelegate());
 627  638      }
 628  639  
 629  640      /**
 630  641       * Format a long to produce a string.
↓ open down ↓ 194 lines elided ↑ open up ↑
 825  836       *
 826  837       * @exception NullPointerException if obj is null.
 827  838       * @exception IllegalArgumentException when the Format cannot format the
 828  839       *            given object.
 829  840       * @exception        ArithmeticException if rounding is needed with rounding
 830  841       *                   mode being set to RoundingMode.UNNECESSARY
 831  842       * @param obj The object to format
 832  843       * @return AttributedCharacterIterator describing the formatted value.
 833  844       * @since 1.4
 834  845       */
      846 +    @Override
 835  847      public AttributedCharacterIterator formatToCharacterIterator(Object obj) {
 836  848          CharacterIteratorFieldDelegate delegate =
 837  849                           new CharacterIteratorFieldDelegate();
 838  850          StringBuffer sb = new StringBuffer();
 839  851  
 840  852          if (obj instanceof Double || obj instanceof Float) {
 841  853              format(((Number)obj).doubleValue(), sb, delegate);
 842  854          } else if (obj instanceof Long || obj instanceof Integer ||
 843  855                     obj instanceof Short || obj instanceof Byte ||
 844  856                     obj instanceof AtomicInteger || obj instanceof AtomicLong) {
↓ open down ↓ 405 lines elided ↑ open up ↑
1250 1262       * consecutive characters starting with the localized zero digit defined in
1251 1263       * the <code>DecimalFormatSymbols</code> object.
1252 1264       *
1253 1265       * @param text the string to be parsed
1254 1266       * @param pos  A <code>ParsePosition</code> object with index and error
1255 1267       *             index information as described above.
1256 1268       * @return     the parsed value, or <code>null</code> if the parse fails
1257 1269       * @exception  NullPointerException if <code>text</code> or
1258 1270       *             <code>pos</code> is null.
1259 1271       */
     1272 +    @Override
1260 1273      public Number parse(String text, ParsePosition pos) {
1261 1274          // special case NaN
1262 1275          if (text.regionMatches(pos.index, symbols.getNaN(), 0, symbols.getNaN().length())) {
1263 1276              pos.index = pos.index + symbols.getNaN().length();
1264 1277              return new Double(Double.NaN);
1265 1278          }
1266 1279  
1267 1280          boolean[] status = new boolean[STATUS_LENGTH];
1268 1281          if (!subparse(text, pos, positivePrefix, negativePrefix, digitList, false, status)) {
1269 1282              return null;
↓ open down ↓ 613 lines elided ↑ open up ↑
1883 1896       * @see #isParseBigDecimal
1884 1897       * @since 1.5
1885 1898       */
1886 1899      public void setParseBigDecimal(boolean newValue) {
1887 1900          parseBigDecimal = newValue;
1888 1901      }
1889 1902  
1890 1903      /**
1891 1904       * Standard override; no change in semantics.
1892 1905       */
     1906 +    @Override
1893 1907      public Object clone() {
1894 1908          DecimalFormat other = (DecimalFormat) super.clone();
1895 1909          other.symbols = (DecimalFormatSymbols) symbols.clone();
1896 1910          other.digitList = (DigitList) digitList.clone();
1897 1911          return other;
1898 1912      }
1899 1913  
1900 1914      /**
1901 1915       * Overrides equals
1902 1916       */
     1917 +    @Override
1903 1918      public boolean equals(Object obj)
1904 1919      {
1905 1920          if (obj == null) return false;
1906 1921          if (!super.equals(obj)) return false; // super does class check
1907 1922          DecimalFormat other = (DecimalFormat) obj;
1908 1923          return ((posPrefixPattern == other.posPrefixPattern &&
1909 1924                   positivePrefix.equals(other.positivePrefix))
1910 1925                  || (posPrefixPattern != null &&
1911 1926                      posPrefixPattern.equals(other.posPrefixPattern)))
1912 1927              && ((posSuffixPattern == other.posSuffixPattern &&
↓ open down ↓ 19 lines elided ↑ open up ↑
1932 1947              && minimumIntegerDigits == other.minimumIntegerDigits
1933 1948              && maximumFractionDigits == other.maximumFractionDigits
1934 1949              && minimumFractionDigits == other.minimumFractionDigits
1935 1950              && roundingMode == other.roundingMode
1936 1951              && symbols.equals(other.symbols);
1937 1952      }
1938 1953  
1939 1954      /**
1940 1955       * Overrides hashCode
1941 1956       */
     1957 +    @Override
1942 1958      public int hashCode() {
1943 1959          return super.hashCode() * 37 + positivePrefix.hashCode();
1944 1960          // just enough fields for a reasonable distribution
1945 1961      }
1946 1962  
1947 1963      /**
1948 1964       * Synthesizes a pattern string that represents the current state
1949 1965       * of this Format object.
1950 1966       * @see #applyPattern
1951 1967       */
↓ open down ↓ 709 lines elided ↑ open up ↑
2661 2677      }
2662 2678  
2663 2679      /**
2664 2680       * Sets the maximum number of digits allowed in the integer portion of a
2665 2681       * number.
2666 2682       * For formatting numbers other than <code>BigInteger</code> and
2667 2683       * <code>BigDecimal</code> objects, the lower of <code>newValue</code> and
2668 2684       * 309 is used. Negative input values are replaced with 0.
2669 2685       * @see NumberFormat#setMaximumIntegerDigits
2670 2686       */
     2687 +    @Override
2671 2688      public void setMaximumIntegerDigits(int newValue) {
2672 2689          maximumIntegerDigits = Math.min(Math.max(0, newValue), MAXIMUM_INTEGER_DIGITS);
2673 2690          super.setMaximumIntegerDigits((maximumIntegerDigits > DOUBLE_INTEGER_DIGITS) ?
2674 2691              DOUBLE_INTEGER_DIGITS : maximumIntegerDigits);
2675 2692          if (minimumIntegerDigits > maximumIntegerDigits) {
2676 2693              minimumIntegerDigits = maximumIntegerDigits;
2677 2694              super.setMinimumIntegerDigits((minimumIntegerDigits > DOUBLE_INTEGER_DIGITS) ?
2678 2695                  DOUBLE_INTEGER_DIGITS : minimumIntegerDigits);
2679 2696          }
2680 2697      }
2681 2698  
2682 2699      /**
2683 2700       * Sets the minimum number of digits allowed in the integer portion of a
2684 2701       * number.
2685 2702       * For formatting numbers other than <code>BigInteger</code> and
2686 2703       * <code>BigDecimal</code> objects, the lower of <code>newValue</code> and
2687 2704       * 309 is used. Negative input values are replaced with 0.
2688 2705       * @see NumberFormat#setMinimumIntegerDigits
2689 2706       */
     2707 +    @Override
2690 2708      public void setMinimumIntegerDigits(int newValue) {
2691 2709          minimumIntegerDigits = Math.min(Math.max(0, newValue), MAXIMUM_INTEGER_DIGITS);
2692 2710          super.setMinimumIntegerDigits((minimumIntegerDigits > DOUBLE_INTEGER_DIGITS) ?
2693 2711              DOUBLE_INTEGER_DIGITS : minimumIntegerDigits);
2694 2712          if (minimumIntegerDigits > maximumIntegerDigits) {
2695 2713              maximumIntegerDigits = minimumIntegerDigits;
2696 2714              super.setMaximumIntegerDigits((maximumIntegerDigits > DOUBLE_INTEGER_DIGITS) ?
2697 2715                  DOUBLE_INTEGER_DIGITS : maximumIntegerDigits);
2698 2716          }
2699 2717      }
2700 2718  
2701 2719      /**
2702 2720       * Sets the maximum number of digits allowed in the fraction portion of a
2703 2721       * number.
2704 2722       * For formatting numbers other than <code>BigInteger</code> and
2705 2723       * <code>BigDecimal</code> objects, the lower of <code>newValue</code> and
2706 2724       * 340 is used. Negative input values are replaced with 0.
2707 2725       * @see NumberFormat#setMaximumFractionDigits
2708 2726       */
     2727 +    @Override
2709 2728      public void setMaximumFractionDigits(int newValue) {
2710 2729          maximumFractionDigits = Math.min(Math.max(0, newValue), MAXIMUM_FRACTION_DIGITS);
2711 2730          super.setMaximumFractionDigits((maximumFractionDigits > DOUBLE_FRACTION_DIGITS) ?
2712 2731              DOUBLE_FRACTION_DIGITS : maximumFractionDigits);
2713 2732          if (minimumFractionDigits > maximumFractionDigits) {
2714 2733              minimumFractionDigits = maximumFractionDigits;
2715 2734              super.setMinimumFractionDigits((minimumFractionDigits > DOUBLE_FRACTION_DIGITS) ?
2716 2735                  DOUBLE_FRACTION_DIGITS : minimumFractionDigits);
2717 2736          }
2718 2737      }
2719 2738  
2720 2739      /**
2721 2740       * Sets the minimum number of digits allowed in the fraction portion of a
2722 2741       * number.
2723 2742       * For formatting numbers other than <code>BigInteger</code> and
2724 2743       * <code>BigDecimal</code> objects, the lower of <code>newValue</code> and
2725 2744       * 340 is used. Negative input values are replaced with 0.
2726 2745       * @see NumberFormat#setMinimumFractionDigits
2727 2746       */
     2747 +    @Override
2728 2748      public void setMinimumFractionDigits(int newValue) {
2729 2749          minimumFractionDigits = Math.min(Math.max(0, newValue), MAXIMUM_FRACTION_DIGITS);
2730 2750          super.setMinimumFractionDigits((minimumFractionDigits > DOUBLE_FRACTION_DIGITS) ?
2731 2751              DOUBLE_FRACTION_DIGITS : minimumFractionDigits);
2732 2752          if (minimumFractionDigits > maximumFractionDigits) {
2733 2753              maximumFractionDigits = minimumFractionDigits;
2734 2754              super.setMaximumFractionDigits((maximumFractionDigits > DOUBLE_FRACTION_DIGITS) ?
2735 2755                  DOUBLE_FRACTION_DIGITS : maximumFractionDigits);
2736 2756          }
2737 2757      }
2738 2758  
2739 2759      /**
2740 2760       * Gets the maximum number of digits allowed in the integer portion of a
2741 2761       * number.
2742 2762       * For formatting numbers other than <code>BigInteger</code> and
2743 2763       * <code>BigDecimal</code> objects, the lower of the return value and
2744 2764       * 309 is used.
2745 2765       * @see #setMaximumIntegerDigits
2746 2766       */
     2767 +    @Override
2747 2768      public int getMaximumIntegerDigits() {
2748 2769          return maximumIntegerDigits;
2749 2770      }
2750 2771  
2751 2772      /**
2752 2773       * Gets the minimum number of digits allowed in the integer portion of a
2753 2774       * number.
2754 2775       * For formatting numbers other than <code>BigInteger</code> and
2755 2776       * <code>BigDecimal</code> objects, the lower of the return value and
2756 2777       * 309 is used.
2757 2778       * @see #setMinimumIntegerDigits
2758 2779       */
     2780 +    @Override
2759 2781      public int getMinimumIntegerDigits() {
2760 2782          return minimumIntegerDigits;
2761 2783      }
2762 2784  
2763 2785      /**
2764 2786       * Gets the maximum number of digits allowed in the fraction portion of a
2765 2787       * number.
2766 2788       * For formatting numbers other than <code>BigInteger</code> and
2767 2789       * <code>BigDecimal</code> objects, the lower of the return value and
2768 2790       * 340 is used.
2769 2791       * @see #setMaximumFractionDigits
2770 2792       */
     2793 +    @Override
2771 2794      public int getMaximumFractionDigits() {
2772 2795          return maximumFractionDigits;
2773 2796      }
2774 2797  
2775 2798      /**
2776 2799       * Gets the minimum number of digits allowed in the fraction portion of a
2777 2800       * number.
2778 2801       * For formatting numbers other than <code>BigInteger</code> and
2779 2802       * <code>BigDecimal</code> objects, the lower of the return value and
2780 2803       * 340 is used.
2781 2804       * @see #setMinimumFractionDigits
2782 2805       */
     2806 +    @Override
2783 2807      public int getMinimumFractionDigits() {
2784 2808          return minimumFractionDigits;
2785 2809      }
2786 2810  
2787 2811      /**
2788 2812       * Gets the currency used by this decimal format when formatting
2789 2813       * currency values.
2790 2814       * The currency is obtained by calling
2791 2815       * {@link DecimalFormatSymbols#getCurrency DecimalFormatSymbols.getCurrency}
2792 2816       * on this number format's symbols.
2793 2817       *
2794 2818       * @return the currency used by this decimal format, or <code>null</code>
2795 2819       * @since 1.4
2796 2820       */
     2821 +    @Override
2797 2822      public Currency getCurrency() {
2798 2823          return symbols.getCurrency();
2799 2824      }
2800 2825  
2801 2826      /**
2802 2827       * Sets the currency used by this number format when formatting
2803 2828       * currency values. This does not update the minimum or maximum
2804 2829       * number of fraction digits used by the number format.
2805 2830       * The currency is set by calling
2806 2831       * {@link DecimalFormatSymbols#setCurrency DecimalFormatSymbols.setCurrency}
2807 2832       * on this number format's symbols.
2808 2833       *
2809 2834       * @param currency the new currency to be used by this decimal format
2810 2835       * @exception NullPointerException if <code>currency</code> is null
2811 2836       * @since 1.4
2812 2837       */
     2838 +    @Override
2813 2839      public void setCurrency(Currency currency) {
2814 2840          if (currency != symbols.getCurrency()) {
2815 2841              symbols.setCurrency(currency);
2816 2842              if (isCurrencyFormat) {
2817 2843                  expandAffixes();
2818 2844              }
2819 2845          }
2820 2846      }
2821 2847  
2822 2848      /**
2823 2849       * Gets the {@link java.math.RoundingMode} used in this DecimalFormat.
2824 2850       *
2825 2851       * @return The <code>RoundingMode</code> used for this DecimalFormat.
2826 2852       * @see #setRoundingMode(RoundingMode)
2827 2853       * @since 1.6
2828 2854       */
     2855 +    @Override
2829 2856      public RoundingMode getRoundingMode() {
2830 2857          return roundingMode;
2831 2858      }
2832 2859  
2833 2860      /**
2834 2861       * Sets the {@link java.math.RoundingMode} used in this DecimalFormat.
2835 2862       *
2836 2863       * @param roundingMode The <code>RoundingMode</code> to be used
2837 2864       * @see #getRoundingMode()
2838 2865       * @exception NullPointerException if <code>roundingMode</code> is null.
2839 2866       * @since 1.6
2840 2867       */
     2868 +    @Override
2841 2869      public void setRoundingMode(RoundingMode roundingMode) {
2842 2870          if (roundingMode == null) {
2843 2871              throw new NullPointerException();
2844 2872          }
2845 2873  
2846 2874          this.roundingMode = roundingMode;
2847 2875          digitList.setRoundingMode(roundingMode);
2848 2876      }
2849 2877  
2850 2878      /**
2851      -     * Adjusts the minimum and maximum fraction digits to values that
2852      -     * are reasonable for the currency's default fraction digits.
2853      -     */
2854      -    void adjustForCurrencyDefaultFractionDigits() {
2855      -        Currency currency = symbols.getCurrency();
2856      -        if (currency == null) {
2857      -            try {
2858      -                currency = Currency.getInstance(symbols.getInternationalCurrencySymbol());
2859      -            } catch (IllegalArgumentException e) {
2860      -            }
2861      -        }
2862      -        if (currency != null) {
2863      -            int digits = currency.getDefaultFractionDigits();
2864      -            if (digits != -1) {
2865      -                int oldMinDigits = getMinimumFractionDigits();
2866      -                // Common patterns are "#.##", "#.00", "#".
2867      -                // Try to adjust all of them in a reasonable way.
2868      -                if (oldMinDigits == getMaximumFractionDigits()) {
2869      -                    setMinimumFractionDigits(digits);
2870      -                    setMaximumFractionDigits(digits);
2871      -                } else {
2872      -                    setMinimumFractionDigits(Math.min(digits, oldMinDigits));
2873      -                    setMaximumFractionDigits(digits);
2874      -                }
2875      -            }
2876      -        }
2877      -    }
2878      -
2879      -    /**
2880 2879       * Reads the default serializable fields from the stream and performs
2881 2880       * validations and adjustments for older serialized versions. The
2882 2881       * validations and adjustments are:
2883 2882       * <ol>
2884 2883       * <li>
2885 2884       * Verify that the superclass's digit count fields correctly reflect
2886 2885       * the limits imposed on formatting numbers other than
2887 2886       * <code>BigInteger</code> and <code>BigDecimal</code> objects. These
2888 2887       * limits are stored in the superclass for serialization compatibility
2889 2888       * with older versions, while the limits for <code>BigInteger</code> and
↓ open down ↓ 373 lines elided ↑ open up ↑
3263 3262      static final int MAXIMUM_INTEGER_DIGITS  = Integer.MAX_VALUE;
3264 3263      static final int MAXIMUM_FRACTION_DIGITS = Integer.MAX_VALUE;
3265 3264  
3266 3265      // Proclaim JDK 1.1 serial compatibility.
3267 3266      static final long serialVersionUID = 864413376551465018L;
3268 3267  
3269 3268      /**
3270 3269       * Cache to hold the NumberPattern of a Locale.
3271 3270       */
3272 3271      private static final ConcurrentMap<Locale, String> cachedLocaleData
3273      -        = new ConcurrentHashMap<Locale, String>(3);
     3272 +        = new ConcurrentHashMap<>(3);
3274 3273  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX