Strings [was Re: Sponsoring getting 5015163 "(str) String merge/join that is the inverse of String.split()" into JDK 7]
kevinb at google.com
Sun Nov 8 23:04:01 UTC 2009
On Mon, Oct 26, 2009 at 1:38 PM, Stephen Colebourne <scolebourne at joda.org>wrote:
Unfortunately, the null-handling behaviour of the static method is
> considered a feature to many
That is unfortunate. <evil grin> Luckily any new JDK methods would not
have to carry forward the null-tolerant approach. :-)
By the way, one advantage of a Strings class is that it could contain a new
> implementation of split - one that doesn't use regex and isn't as
> complex/useless as the current one on String.
Different splitting use cases want to specify the delimiter as any of a
regex, a literal String, a literal char, or what we (Guava) call a
"CharMatcher". One way to support all these is to just support regex, as
any of the rest of these can be coerced into a regex; this is what
String.split() does. Another way is to just outright support them all, as
Guava's Splitter does:
It also supports splitting into fixed-width segments, which -- well, I guess
that can be coerced into a regex too, just a really frickin' weird one.
Splitter has a few other optional behaviors that users depend on. The point
of all this is that doing splitting well is going to take more than just a
few static methods in a utility class. By and large, we've found this to be
the case with nearly everything (but not everything) we first thought of as
a StringUtil method.
Kevin Bourrillion @ Google
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the core-libs-dev