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

change parameter type from String to CharSequence in numeric parse methods

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Won't Fix
    • Icon: P4 P4
    • None
    • 1.4.2
    • core-libs

      Name: rmT116609 Date: 11/10/2003


      A DESCRIPTION OF THE REQUEST :
      Now that the CharSequence interface exists, the parameters of numeric parse
      methods (e.g., Integer.parseInt(String)) should probably be changed from
      type String to type CharSequence.

      This applies to:
      * The java.lang.<numeric type> classes:
        - Byte.parseByte(...) methods
        - Short.parseShort(...) methods
        - Integer.parseInt(...) methods
        - Long.parseLong(...) methods
        - Float.parseFloat(...) method
        - Double.parseDouble(...) method
      * java.util.Format classes:
        - java.util.Format.parseObject(...)
        - subclass parse(...) methods


      JUSTIFICATION :
      If nothing else, this change seems like something that should have been done
      with the introduction of CharSequence in the first place.

      Particularly, it would allow calling the numeric parse methods without having
      to create a String object containing just the numeric characters (for example
      if the caller has a character array, or a bigger String, within which it has
      identified the position of numeric characters).
      (Incident Review ID: 224683)
      ======================================================================
      ###@###.### 10/28/04 01:10 GMT
      In addition to the parse methods, bug 4838318 also requests that the following numeric methods also have CharSequence parameters:

        Integer(String s)
        Integer.valueOf(String s)
        Double(String s)

      Clearly this recommendation would need to be applied to all of the wrapper classes, not just Integer and Double.

            darcy Joe Darcy
            rmandalasunw Ranjith Mandala (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: