Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8220453

MinusSign/Percent/PerMille access methods in DecimalFormatSymbols

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Unresolved
    • Icon: P4 P4
    • None
    • core-libs
    • None
    • minimal
    • Risk is minimal, as this CSR intends to add new methods/fields which is backward compatible to JDK1.1

      Summary

      Add equivalent methods to existing get/setPerMill(), get/setPercent(), and get/setMinusSign(), which deal with String representations of fields.

      Problem

      Existing methods can only handle char for those elements which is inadequate for cases such as BiDi control characters are involved.

      Solution

      Provide new methods to existing methods through String arguments. For setter methods, either char version or String version is issued, it will affect the other sort of methods. For example, if setMinusSign(char) is called, getMinusSignText() that returns String representation of minus sign will be replaced with the specified character.

      Specification

      Add the following new methods to java.text.DecimalFormatSymbols

      /**
       * Gets the string used for per mille sign. Different for Arabic, etc.
       *
       * @return the string used for per mille sign
       * @since 13
       */
      public String getPerMillText() 
      
      /**
       * Sets the string used for per mille sign. Different for Arabic, etc.
       *
       * Setting the {@code perMillText} affects the return value of
       * {@link #getPerMill()}, in which the first character of {@code perMillText}
       * is returned.
       *
       * @param perMillText the string used for per mille sign
       * @throws NullPointerException if {@code perMillText} is null
       * @throws IllegalArgumentException if {@code perMillText} is an empty string
       * @see #getPerMill()
       * @see #getPerMillText()
       * @since 13
       */
      public void setPerMillText(String perMillText)
      
      /**
       * Gets the string used for percent sign. Different for Arabic, etc.
       *
       * @return the string used for percent sign
       * @since 13
       */
      public String getPercentText() 
      
      /**
       * Sets the string used for percent sign. Different for Arabic, etc.
       *
       * Setting the {@code percentText} affects the return value of
       * {@link #getPercent()}, in which the first character of {@code percentText}
       * is returned.
       *
       * @param percentText the string used for percent sign
       * @throws NullPointerException if {@code percentText} is null
       * @throws IllegalArgumentException if {@code percentText} is an empty string
       * @see #getPercent()
       * @see #getPercentText()
       * @since 13
       */
      public void setPercentText(String percentText)
      
      /**
       * Gets the string used to represent minus sign. If no explicit
       * negative format is specified, one is formed by prefixing
       * minusSignText to the positive format.
       *
       * @return the string representing minus sign
       * @since 13
       */
      public String getMinusSignText()
      
      /**
       * Sets the string used to represent minus sign. If no explicit
       * negative format is specified, one is formed by prefixing
       * minusSignText to the positive format.
       *
       * Setting the {@code minusSignText} affects the return value of
       * {@link #getMinusSign()}, in which the first character of
       * {@code minusSignText} is returned.
       *
       * @param minusSignText the character representing minus sign
       * @throws NullPointerException if {@code minusSignText} is null
       * @throws IllegalArgumentException if {@code minusSignText} is an
       *  empty string
       * @see #getMinusSign()
       * @see #getMinusSignText()
       * @since 13
       */
      public void setMinusSignText(String minusSignText)

      Change the method descriptions of the corresponding char version of setter methods to:

      /**
       * Sets the character used for per mille sign. Different for Arabic, etc.
       *
       * Setting {@code perMill} replaces the return value of
       * {@link #getPerMillText()} with the string containing {@code perMill}.
       *
       * @param perMill the character used for per mille sign
       * @see #getPerMill()
       * @see #getPerMillText()
       */
      public void setPerMill(char perMill)
      
      /**
       * Sets the character used for percent sign. Different for Arabic, etc.
       *
       * Setting {@code percent} replaces the return value of
       * {@link #getPercentText()} with the string containing {@code percent}.
       *
       * @param percent the character used for percent sign
       * @see #getPercent()
       * @see #getPercentText()
       */
      public void setPercent(char percent)
      
      /**
       * Sets the character used to represent minus sign. If no explicit
       * negative format is specified, one is formed by prefixing
       * minusSign to the positive format.
       *
       * Setting {@code minusSign} replaces the return value of
       * {@link #getMinusSignText()} with the string containing {@code minusSign}.
       *
       * @param minusSign the character representing minus sign
       * @see #getMinusSign()
       * @see #getMinusSignText()
       */
      public void setMinusSign(char minusSign)

      Add the following paragraph to readObject method description:

       * If <code>serialVersionOnStream</code> is less than 4, it initializes
       * <code>perMillText</code>, <code>percentText</code>, and
       * <code>minusSignText</code> using <code>perMill</code>, <code>percent</code>, and
       * <code>minusSign</code> respectively.

      Add the following new serializable fields:

      /**
       * String used for per mille sign.
       * The first character of this string is the same as <code>perMill</code>.
       *
       * @serial
       * @see #getPerMillText
       * @since 13
       */
      private  String perMillText;
      
      /**
       * String used for percent sign.
       * The first character of this string is the same as <code>percent</code>.
       *
       * @serial
       * @see #getPercentText
       * @since 13
       */
      private  String percentText;
      
      /**
       * String used to represent minus sign.
       * The first character of this string is the same as <code>minusSign</code>.
       *
       * @serial
       * @see #getMinusSignText
       * @since 13
       */
      private  String minusSignText;

      Change the serialVersionOnStream to 4, and insert the following list item in the description:

       * <li><b>4</b>: Versions written by Java SE 13 or later, which include
       *      new <code>perMillText</code>, <code>percentText</code>, and
       *      <code>minusSignText</code> field.
       * </ul>

            naoto Naoto Sato
            naoto Naoto Sato
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated: