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

(str) String format method as an instance method

    XMLWordPrintable

    Details

    • Type: Enhancement
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: 6u26, 7
    • Fix Version/s: None
    • Component/s: core-libs
    • Labels:

      Description

      A DESCRIPTION OF THE REQUEST :
        To make a version of the String format method, wich today is a static method, as an instance method,
      without modifing the string itself, just returning a version of it formatted.

      Imagine you have a label into your application and you want to set it text from a string obtained from a properties file or from a database table. The string use some formatting tags ( %s, %d, etc ), you have to do

      String model = "This is my Model String using %s";
      myLabel.setText( String.format(model, "Fool") );

      result: myLabel get the text set to : "This is my Model String using Fool", and model stais unchanged.

      The code would get cleanner if possible to do something like:

      myLabel.setText( model.format("Fool") );

      result: myLabel get the text set to : "This is my Model String using Fool", and model stais unchanged.


      JUSTIFICATION :
      It would be very usefull to print out formatted strings calling the string object itself. Making the code cleaner.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Imported:
                Indexed: