Commons Lang
  1. Commons Lang
  2. LANG-330

Add StringBufferUtils or overload StringUtils methods

    Details

    • Type: New Feature New Feature
    • Status: Closed
    • Priority: Major Major
    • Resolution: Duplicate
    • Affects Version/s: None
    • Fix Version/s: 3.0
    • Component/s: lang.*
    • Labels:
      None

      Description

      There's especially one group of methods you should overload with StringBuffer (or Appendable in a special JDK5 Class?):
      StringUtils.join

      It should take a StringBuffer (/Appendable) as first Argument to which the Strings will be added.

      Usage Example:

      StringBuffer sql = new StringBuffer("SELECT * FROM foo WHERE bar IN (");
      StringUtils.join(sql, bars, ", ");
      sql.append(") AND bar NOT IN (");
      StringUtils.join(sql, noBars, ", ");
      sql.append(");");

        Activity

        Hide
        Henri Yandell added a comment -

        Duplicate of the later LANG-542 (in terms of adding Appendable as an API element). I don't see a StringBufferUtils being likely, especially with StringBuilderUtils in existence.

        Possibly we could have an AppendableUtils or StringUtils overload for Appendable options that the String option would sit on top of (and hide the IOException).

        Show
        Henri Yandell added a comment - Duplicate of the later LANG-542 (in terms of adding Appendable as an API element). I don't see a StringBufferUtils being likely, especially with StringBuilderUtils in existence. Possibly we could have an AppendableUtils or StringUtils overload for Appendable options that the String option would sit on top of (and hide the IOException).
        Hide
        Henri Yandell added a comment -

        Note that it's 2 duplicates for repeat.

        Show
        Henri Yandell added a comment - Note that it's 2 duplicates for repeat.
        Hide
        Henri Yandell added a comment -

        Had hopes I could delete the join variants that take a char, but after a quick performance test there is a notable 10% speed improvement (array of 100 length 10 Strings) to using a char over a single character String separator.

        Show
        Henri Yandell added a comment - Had hopes I could delete the join variants that take a char, but after a quick performance test there is a notable 10% speed improvement (array of 100 length 10 Strings) to using a char over a single character String separator.
        Hide
        Henri Yandell added a comment -

        Also tempted to consider for repeat(...),

        Downside of this is that it potentially means duplicating the entire API for each method. 9 methods for join, 1 method for repeat.

        Still - not sounding like enough yet to warrant the painfully named AppendableUtils.

        Show
        Henri Yandell added a comment - Also tempted to consider for repeat(...), Downside of this is that it potentially means duplicating the entire API for each method. 9 methods for join, 1 method for repeat. Still - not sounding like enough yet to warrant the painfully named AppendableUtils.
        Hide
        Henri Yandell added a comment -

        Appendable sounds like an attractive jdk 5 feature; setting the fixVersion to that as a part of the Lang2 thinking.

        Show
        Henri Yandell added a comment - Appendable sounds like an attractive jdk 5 feature; setting the fixVersion to that as a part of the Lang2 thinking.

          People

          • Assignee:
            Unassigned
            Reporter:
            Jörg Gottschling
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development