commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Benedikt Ritter <brit...@apache.org>
Subject Re: [LANG] Handling of empty string in StringUtils
Date Fri, 17 Jan 2014 12:20:06 GMT
2014/1/15 Benedikt Ritter <britter@apache.org>

>
>
>
> 2014/1/13 Paul Benedict <pbenedict@apache.org>
>
>> Splitting with an empty string doesn't make any sense to me. Nothing
>> should
>> match that -- even an empty string. It's a lack of a token.
>>
>
> Okay, and that's the reason why currently
>
> StringUtils.split("", ".") = [ ]
> but
> StringUtils.split("x", ".") = ["x"]
>
> I guess I understand the rationale behind this, but it feels a bit counter
> intuitive.
>

How do others feel? Should StringUtils.split("", *) return [ "" ]?

I've found another one that doesn't feel right:

StringUtils. isAlphaSpace(CharSequence cs) return true for the empty
string. That doesn't make sense to me, since the empty string is not a
whitespace character nor a letter.

I'm still not sure if we have consensus here about changing this stuff.

Benedikt


>
>
>>
>> On Mon, Jan 13, 2014 at 11:00 AM, Benedikt Ritter <britter@apache.org
>> >wrote:
>>
>> > ping, any thought on this?
>> >
>> >
>> > 2014/1/11 Benedikt Ritter <britter@apache.org>
>> >
>> > > Hi,
>> > >
>> > > while looking through the open issues for lang, I came across
>> LANG-823:
>> > > StringUtils.split should handle empty strings the same as other
>> content
>> > > [1]. The request makes sense to me - the empty string should be
>> handled
>> > > like any other content.
>> > >
>> > > Then I looked into StringUtils to see how other methods handle the
>> empty
>> > > string and there are more examples of specific handling of the empty
>> > > string. For example the following will return true:
>> > >
>> > >    StringUtils.containsOnly("", "abc")
>> > >
>> > > and it gets even more weird, since
>> > >
>> > >    StringUtils.containsNone("", "abc")
>> > >
>> > > also returns true! How can the same string a the same time _only_
>> contain
>> > > "abc" and contain none of "abc"?
>> > >
>> > > I can not see any reason for this behavior. Why is the empty string
>> > > different from any other string content? I'd like to change the
>> behavior
>> > of
>> > > the affected methods, but wanted to get some feedback first.
>> > >
>> > > Benedikt
>> > >
>> > > [1] https://issues.apache.org/jira/browse/LANG-823
>> > >
>> > >
>> > > --
>> > > http://people.apache.org/~britter/
>> > > http://www.systemoutprintln.de/
>> > > http://twitter.com/BenediktRitter
>> > > http://github.com/britter
>> > >
>> >
>> >
>> >
>> > --
>> > http://people.apache.org/~britter/
>> > http://www.systemoutprintln.de/
>> > http://twitter.com/BenediktRitter
>> > http://github.com/britter
>> >
>>
>>
>>
>> --
>> Cheers,
>> Paul
>>
>
>
>
> --
> http://people.apache.org/~britter/
> http://www.systemoutprintln.de/
> http://twitter.com/BenediktRitter
> http://github.com/britter
>



-- 
http://people.apache.org/~britter/
http://www.systemoutprintln.de/
http://twitter.com/BenediktRitter
http://github.com/britter

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message