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

(str) Add the regex-related functions to StringBuffer and StringBuilder

    Details

    • Subcomponent:
    • Understanding:
      Fix Understood
    • CPU:
      x86
    • OS:
      windows_2000

      Description

      Name: jl125535 Date: 04/05/2004


      A DESCRIPTION OF THE REQUEST :
      When writing code that does a lot of string manipulation, I find myself having to switch between String and StringBuffers because StringBuffers lack the new regex functionality.


        matches(String regex)
        replaceAll(String regex, String replacement)
        replaceFirst(String regex, String replacement)

      These are less important, because they are less likely to
      result in needing to convert the result back into a StringBuffer.
        split(String regex)
        split(String regex, int limit)

      In JDK1.5, These comments apply to StringBuilder as well as to StringBuffer.

      I note that there are a bunch of other differences as well between String and StringBuffer as well, but I understand that is likely these were left out keep the size of the API reasonable.
        implements Comparable
        compareTo(StringBuffer)
        compareToIgnoreCase(StringBuffer)
        contains(String)
        endsWith(String)
        equals(StringBuffer)
        equalsIgnoreCase(StringBuffer)
        format(Locale l, String format, Object ... args) [1.5]
        format(String format, Object ... args) [1.5]
        indexOf(int ch)
        indexOf(int ch, int fromIndex)
        lastIndexOf(int ch)
        lastIndexOf(int ch, int fromIndex)
        regionMatches(boolean ignoreCase, int toffset, StringBuffer other, int ooffset, int len)
        regionMatches(int toffset, StringBuffer other, int ooffset, int len)
        startsWith(String prefix)
        startsWith(String prefix, int toffset)


      JUSTIFICATION :
      StringBuffer is supposed to be a replacement for String when lots of editing takes place. It is supposed to, at minimum, support all of the functionality present in String.



      CUSTOMER SUBMITTED WORKAROUND :
      Lots of:
      StringBuffer buf = new StringBuffer(s)
      ...manipulation....
      s = buf.toString();
      ...manipulation....
      buf = new StringBuffer(s);
      ...manipulation....
      (Incident Review ID: 240654)
      ======================================================================

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              jleesunw Jon Lee (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Imported:
                Indexed: